Give a new shape to the array without changing its data.
Returns a masked array containing the same data, but with a new shape. The result is a view on the original array; if this is not possible, a ValueError is raised.
Parameters: | shape : int or tuple of ints
order : {‘C’, ‘F’}, optional
|
---|---|
Returns: | reshaped_array : array
|
See also
Notes
The reshaping operation cannot guarantee that a copy will not be made, to modify the shape in place, use a.shape = s
Examples
>>> x = np.ma.array([[1,2],[3,4]], mask=[1,0,0,1])
>>> print x
[[-- 2]
[3 --]]
>>> x = x.reshape((4,1))
>>> print x
[[--]
[2]
[3]
[--]]