numpy / 1.22.0 / reference / generated / numpy.ndarray.newbyteorder.html /

numpy.ndarray.newbyteorder

method

ndarray. newbyteorder ( new_order='S', / )

Return the array with the same data viewed with a different byte order.

Equivalent to:

arr.view(arr.dtype.newbytorder(new_order))

Changes are also made in all fields and sub-arrays of the array data type.

Parameters
new_order string, optional

Byte order to force; a value from the byte order specifications below. new_order codes can be any of:

  • ‘S’ - swap dtype from current to opposite endian
  • {‘<’, ‘little’} - little endian
  • {‘>’, ‘big’} - big endian
  • {‘=’, ‘native’} - native order, equivalent to sys.byteorder
  • {‘|’, ‘I’} - ignore (no change to byte order)

The default value (‘S’) results in swapping the current byte order.

Returns
new_arr array

New array object with the dtype reflecting given change to the byte order.

© 2005–2021 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.22/reference/generated/numpy.ndarray.newbyteorder.html