numpy.ma.squeeze(a,axis=None)[source]¶Remove single-dimensional entries from the shape of an array.
| Parameters: | a : array_like
axis : None or int or tuple of ints, optional
|
|---|---|
| Returns: | squeezed : ndarray
|
| Raises: | ValueError
|
See also
expand_dimsreshapeExamples
>>>x=np.array([[[0],[1],[2]]])>>>x.shape(1, 3, 1)>>>np.squeeze(x).shape(3,)>>>np.squeeze(x,axis=0).shape(3, 1)>>>np.squeeze(x,axis=1).shapeTraceback (most recent call last):...ValueError:cannot select an axis to squeeze out which has size not equal to one>>>np.squeeze(x,axis=2).shape(1, 3)