Numpy ndarray.tobytes() function | Python Last Updated : 22 Apr, 2020 Comments Improve Suggest changes Like Article Like Report numpy.ndarray.tobytes() function construct Python bytes containing the raw data bytes in the array. Syntax : numpy.ndarray.tobytes(order='C') Parameters : order : [{‘C’, ‘F’, None}, optional] Order of the data for multidimensional arrays: C, Fortran, or the same as for the original array. Return : Python bytes exhibiting a copy of arr’s raw data. Code #1 : Python3 # Python program explaining # numpy.ndarray.tobytes() function # importing numpy as geek import numpy as geek arr = geek.array([[0, 1], [2, 3]], dtype ='<u2') gfg = arr.tobytes() print (gfg) Output : b'\x00\x00\x01\x00\x02\x00\x03\x00' Code #2 : Python3 # Python program explaining # numpy.ndarray.tobytes() function # importing numpy as geek import numpy as geek arr = geek.array([[0, 1], [2, 3]], dtype ='<u2') gfg = arr.tobytes('F') print (gfg) Output : b'\x00\x00\x02\x00\x01\x00\x03\x00' Comment More infoAdvertise with us Next Article Numpy ndarray.tobytes() function | Python S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy Python numpy-ndarray python Practice Tags : Machine Learningpython Similar Reads Numpy ndarray.setfield() function | Python numpy.ndarray.setfield() function Put a value into a specified place in a field defined by a data-type. Place val into aâs field defined by dtype and beginning offset bytes into the field. Syntax : numpy.ndarray.setfield(val, dtype, offset=0) Parameters : val : [object] Value to be placed in field. 1 min read Numpy MaskedArray.ravel() function | Python numpy.MaskedArray.ravel() function is used to return a 1D version of self mask array, as a view. Syntax : numpy.ma.ravel(self, order='C') Parameters: order : [âCâ, âFâ, âAâ, âKâ, optional] By default, âCâ index order is used. --> The elements of a are read using this index order. --> âCâ means to in 2 min read Numpy recarray.tobytes() function | Python In numpy, arrays may have a data-types containing fields, analogous to columns in a spreadsheet. An example is [(a, int), (b, float)], where each entry in the array is a pair of (int, float). Normally, these attributes are accessed using dictionary lookups such as arr['a'] and arr['b']. Record array 3 min read numpy.ndarray.view() in Python numpy.ndarray.view() helps to get a new view of array with the same data. Syntax: ndarray.view(dtype=None, type=None)Parameters: dtype : Data-type descriptor of the returned view, e.g., float32 or int16. The default, None, results in the view having the same data-type as a. type : Python type, opti 3 min read Numpy ndarray.getfield() function | Python numpy.ndarray.getfield() function return a field of the given array as a certain type. Syntax : numpy.ndarray.getfield(dtype, offset=0) Parameters : dtype : [str or dtype] The dtype size of the view can not be larger than that of the array itself. offset : [int] Number of bytes to skip before beginn 1 min read Like