polars.Series.is_close
-
Get a boolean mask of the values being close to the other values.
Two values
aandbare considered close if the following condition holds:\[|a-b| \le max \{ \text{rel_tol} \cdot max \{ |a|, |b| \}, \text{abs_tol} \}\]- Parameters:
-
- other
-
A literal or expression value to compare with.
- 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 ]
Series.is_close(
other: IntoExpr,
*,
abs_tol: float = 0.0,
rel_tol: float = 1e-09,
nans_equal: bool = False,
) → Series
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/series/api/polars.Series.is_close.html