Returns an array containing the same data with a new shape.
Refer to MaskedArray.reshape for full documentation.
See also
MaskedArray.reshapeequivalent function
Reshaping a 1-D array:
>>> a = np.ma.array([1, 2, 3, 4])
>>> np.ma.reshape(a, (2, 2))
masked_array(
data=[[1, 2],
[3, 4]],
mask=False,
fill_value=999999)
Reshaping a 2-D array:
>>> b = np.ma.array([[1, 2], [3, 4]])
>>> np.ma.reshape(b, (1, 4))
masked_array(data=[[1, 2, 3, 4]],
mask=False,
fill_value=999999)
Reshaping a 1-D array with a mask:
>>> c = np.ma.array([1, 2, 3, 4], mask=[False, True, False, False])
>>> np.ma.reshape(c, (2, 2))
masked_array(
data=[[1, --],
[3, 4]],
mask=[[False, True],
[False, False]],
fill_value=999999)
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.ma.reshape.html