Field.squeeze(axes=None, inplace=False, i=False, **kwargs)[source]

Remove size-1 axes from the data array.

By default all size 1 axes are removed, but particular size 1 axes may be selected for removal.

Squeezed domain axis constructs are not removed from the metadata contructs, nor from the domain.

axes: (sequence of) str or int, optional

Select the domain axes to squeeze, defined by the domain axes that would be selected by passing the each given axis description to a call of the field construct’s domain_axis method. For example, for a value of 'X', the domain axis construct returned by f.domain_axis('X')) is selected.

If no axes are provided then all size-1 axes are squeezed.

inplace: bool, optional

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

i: deprecated at version 3.0.0

Use the inplace parameter instead.

kwargs: deprecated at version 3.0.0

Field or None

The field construct with squeezed data, or None if the operation was in-place.


>>> g = f.squeeze()
>>> g = f.squeeze('time')
>>> g = f.squeeze(1)
>>> g = f.squeeze(['time', 1, 'dim2'])
>>> f.squeeze(['dim2'], inplace=True)