diff options
author | Miguel de Val-Borro <miguel.deval@gmail.com> | 2013-11-11 13:45:51 -0500 |
---|---|---|
committer | Miguel de Val-Borro <miguel.deval@gmail.com> | 2013-11-11 13:46:52 -0500 |
commit | e1e021dde998b778de0f1adb397abc523a4ccb62 (patch) | |
tree | 3e199160cded26ead419490e9876983f28405e53 /numpy/doc/byteswapping.py | |
parent | 6132b9832d06a81457ff931c42ac09408f7b0398 (diff) | |
download | numpy-e1e021dde998b778de0f1adb397abc523a4ccb62.tar.gz |
DOC: Add an example of casting array type and byte order using astype.
Diffstat (limited to 'numpy/doc/byteswapping.py')
-rw-r--r-- | numpy/doc/byteswapping.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/numpy/doc/byteswapping.py b/numpy/doc/byteswapping.py index 8632e9794..ffefe3168 100644 --- a/numpy/doc/byteswapping.py +++ b/numpy/doc/byteswapping.py @@ -134,5 +134,14 @@ the previous operations: >>> swapped_end_arr.tostring() == big_end_str False +An easier way of casting the data to a specific dtype and byte ordering +can be achieved with the ndarray astype method: + +>>> swapped_end_arr = big_end_arr.astype('<i2') +>>> swapped_end_arr[0] +1 +>>> swapped_end_arr.tostring() == big_end_str +False + """ from __future__ import division, absolute_import, print_function |