cf.Field.trunc

Field.trunc(*args, **kwargs)[source]

Truncate the data, element-wise.

The truncated value of the scalar x, is the nearest integer i which is closer to zero than x is. I.e. the fractional part of the signed number x is discarded.

New in version 1.0.

See also

ceil, floor, rint

Parameters
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.

Returns
Field or None

The construct with truncated data. If the operation was in-place then None is returned.

Examples

>>> print(f.array)
[-1.9 -1.5 -1.1 -1.   0.   1.   1.1  1.5  1.9]
>>> print(f.trunc().array)
[-1. -1. -1. -1.  0.  1.  1.  1.  1.]
>>> f.trunc(inplace=True)
>>> print(f.array)
[-1. -1. -1. -1.  0.  1.  1.  1.  1.]