cfdm.Field.squeeze¶
-
Field.
squeeze
(axes=None, inplace=False)[source]¶ Remove size 1 axes from the data.
By default all size one axes are removed, but particular size one axes may be selected for removal.
Squeezed domain axis constructs are not removed from the metadata constructs, nor from the domain of the field construct.
New in version (cfdm): 1.7.0
See also
- Parameters
- axes:
Select the domain axes to squeeze, defined by the domain axes that would be selected by passing each given axis description to a call of the field construct’s
domain_axis
method. For example, for a value of'time'
, the domain axis construct returned byf.domain_axis('time')
is selected.If axes is
None
(the default) then all size 1 axes are removed.- inplace:
bool
, optional If True then do the operation in-place and return
None
.
- Returns
Examples
>>> g = f.squeeze() >>> g = f.squeeze('time') >>> g = f.squeeze(1) >>> g = f.squeeze(['time', 1, 'dim2']) >>> f.squeeze(['dim2'], inplace=True)