diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-11-11 18:56:19 -0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-11-11 18:56:19 -0800 |
commit | 4d0076f7e783f42dffb742063d8a05b78ba1e942 (patch) | |
tree | 3e199160cded26ead419490e9876983f28405e53 /numpy/doc/byteswapping.py | |
parent | 6132b9832d06a81457ff931c42ac09408f7b0398 (diff) | |
parent | e1e021dde998b778de0f1adb397abc523a4ccb62 (diff) | |
download | numpy-4d0076f7e783f42dffb742063d8a05b78ba1e942.tar.gz |
Merge pull request #4037 from migueldvb/docs
Example to convert the type of an array using the astype method and minor typo fix
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 |