numpy.recarray.setfield
method
- 
recarray.setfield(val, dtype, offset=0) - 
Put a value into a specified place in a field defined by a data-type.
Place
valintoa’s field defined bydtypeand beginningoffsetbytes into the field.- Parameters
 - 
- 
valobject - 
Value to be placed in field.
 - 
dtypedtype object - 
Data-type of the field in which to place
val. - 
offsetint, optional - 
The number of bytes into the field at which to place
val. 
 - 
 - Returns
 - 
- None
 
 
See also
Examples
>>> x = np.eye(3) >>> x.getfield(np.float64) array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) >>> x.setfield(3, np.int32) >>> x.getfield(np.int32) array([[3, 3, 3], [3, 3, 3], [3, 3, 3]], dtype=int32) >>> x array([[1.0e+000, 1.5e-323, 1.5e-323], [1.5e-323, 1.0e+000, 1.5e-323], [1.5e-323, 1.5e-323, 1.0e+000]]) >>> x.setfield(np.eye(3), np.int32) >>> x array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) 
    © 2005–2021 NumPy Developers
Licensed under the 3-clause BSD License.
    https://numpy.org/doc/1.21/reference/generated/numpy.recarray.setfield.html