cfdm.Data.squeeze

Data.squeeze(axes=None, inplace=False)[source]

Remove size 1 axes from the data array.

By default all size 1 axes are removed, but particular axes may be selected with the keyword arguments.

New in version (cfdm): 1.7.0

Parameters
axes: (sequence of) int, optional

Select the axes. By default all size 1 axes are removed. Each axis is identified by its positive or negative integer position. No axes are removed if axes is an empty sequence.

inplace: bool, optional

If True then do the operation in-place and return None.

Returns
Data or None

The squeezed data array.

Examples

>>>
>>> v.shape
(1,)
>>> v.squeeze()
>>> v.shape
()
>>>
>>> v.shape
(1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1)
>>> v.squeeze((0,))
>>> v.shape
(2, 1, 3, 1, 4, 1, 5, 1, 6, 1)
>>> v.squeeze(1)
>>> v.shape
(2, 3, 1, 4, 1, 5, 1, 6, 1)
>>> v.squeeze([2, 4])
>>> v.shape
(2, 3, 4, 5, 1, 6, 1)
>>> v.squeeze([])
>>> v.shape
(2, 3, 4, 5, 1, 6, 1)
>>> v.squeeze()
>>> v.shape
(2, 3, 4, 5, 6)