cfdm.Data.squeeze

Data.squeeze(axes=None)[source]

Remove size 1 axes from the data.

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

New in version 1.7.0.

Parameters:
axes: (sequence of) int, optional

The positions of the size one axes to be removed. By default all size one axes are removed. Each axis is identified by its original integer position. Negative integers counting from the last position are allowed.

Parameter example:

axes=0

Parameter example:

axes=-2

Parameter example:

axes=[2, 0]

Returns:
Data

The new data array with removed data axes.

Examples:

>>> d.shape
(1, 73, 1, 96)
>>> f.squeeze().shape
(73, 96)
>>> d.squeeze(0).shape
(73, 1, 96)
>>> d.squeeze([-3, 2]).shape
(73, 96)