polars.Series.is_close#
- Series.is_close( ) Series [source]#
Get a boolean mask of the values being close to the other values.
Two values
a
andb
are considered close if the following condition holds:\[|a-b| \le max \{ \text{rel_tol} \cdot max \{ |a|, |b| \}, \text{abs_tol} \}\]- Parameters:
- abs_tol
Absolute tolerance. This is the maximum allowed absolute difference between two values. Must be non-negative.
- rel_tol
Relative tolerance. This is the maximum allowed difference between two values, relative to the larger absolute value. Must be non-negative.
- nans_equal
Whether NaN values should be considered equal.
- Returns:
- Series
Series of data type
Boolean
.
Notes
The implementation of this method is symmetric and mirrors the behavior of
math.isclose()
. Specifically note that this behavior is different tonumpy.isclose()
.Examples
>>> s = pl.Series("s", [1.0, 1.2, 1.4, 1.45, 1.6]) >>> s.is_close(1.4, abs_tol=0.1) shape: (5,) Series: 's' [bool] [ false false true true false ]