From e1e021dde998b778de0f1adb397abc523a4ccb62 Mon Sep 17 00:00:00 2001 From: Miguel de Val-Borro Date: Mon, 11 Nov 2013 13:45:51 -0500 Subject: DOC: Add an example of casting array type and byte order using astype. --- numpy/doc/byteswapping.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'numpy/doc/byteswapping.py') 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('>> swapped_end_arr[0] +1 +>>> swapped_end_arr.tostring() == big_end_str +False + """ from __future__ import division, absolute_import, print_function -- cgit v1.2.1