Numpy ndarray.setfield() function | Python Last Updated : 22 Apr, 2020 Comments Improve Suggest changes Like Article Like Report 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. dtype : [dtype object] Data-type of the field in which to place val. offset : [int, optional] The number of bytes into the field at which to place val. Return : None. Code #1 : Python3 # Python program explaining # numpy.ndarray.setfield() function # importing numpy as geek import numpy as geek arr = geek.eye(4) arr.setfield(4, geek.int32) gfg = arr.getfield(geek.int32) print(gfg) Output : [[4 4 4 4] [4 4 4 4] [4 4 4 4] [4 4 4 4]] Code #2 : Python3 # Python program explaining # numpy.ndarray.setfield() function # importing numpy as geek import numpy as geek arr = geek.eye(2) arr.setfield(2, geek.int32) gfg = arr.getfield(geek.int32) print(gfg) Output : [[2 2] [2 2]] Comment More infoAdvertise with us Next Article Numpy ndarray.setfield() 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.resize() function - Python numpy.ndarray.resize() function change shape and size of array in-place. Syntax : numpy.ndarray.resize(new_shape, refcheck = True) Parameters : new_shape :[tuple of ints, or n ints] Shape of resized array. refcheck :[bool, optional] If False, reference count will not be checked. Default is True. Ret 1 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.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 numpy.ndarray.flat() in Python The numpy.ndarray.flat() function is used as a 1_D iterator over N-dimensional arrays. It is not a subclass of, Pythonâs built-in iterator object, otherwise it a numpy.flatiter instance. Syntax : numpy.ndarray.flat() Parameters : index : [tuple(int)] index of the values to iterate Return :  1-D i 3 min read Like