Numpy ndarray.getfield() function | Python Last Updated : 22 Apr, 2020 Comments Improve Suggest changes Like Article Like Report 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 beginning the element view. Return : Returns a field of the given array as a certain type. Code #1 : Python3 # Python program explaining # numpy.ndarray.getfield() function # importing numpy as geek import numpy as geek x = geek.diag([1.+1.j]*2) gfg = x.getfield(geek.float64) print(gfg) Output : [[ 1. 0.] [ 0. 1.]] Code #2 : Python3 # Python program explaining # numpy.ndarray.getfield() function # importing numpy as geek import numpy as geek x = geek.diag([2.+2.j]*2) gfg = x.getfield(geek.float64, offset = 8) print(gfg) Output : [[ 2. 0.] [ 0. 2.]] Comment More infoAdvertise with us Next Article Numpy ndarray.getfield() 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.flatten() function in Python The flatten() function is used to convert a multi-dimensional NumPy array into a one-dimensional array. It creates a new copy of the data so that original array stays unchanged. If your array has rows and columns or even more dimensions, then flatten() line up every single value into a straight list 3 min read Numpy ndarray.tobytes() function | Python 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 : P 1 min read 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 Python | Numpy ndarray.__iand__() With the help of Numpy ndarray.__iand__() method, we can get the elements that is anded by the value that is provided as a parameter in numpy.ndarray.__iand__() method. Syntax: ndarray.__iand__($self, value, /) Return: self&=value Example #1 : In this example we can see that every element is and 1 min read Python | Numpy ndarray.item() With the help of numpy.ndarray.item() method, we can fetch the data elements that is found at the given index on numpy array. Remember we can give index as one dimensional parameter or can be two dimensional. Parameters: *args : Arguments (variable number and type) -> none: This argument only works 2 min read Like