1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::prelude::*;
use num::Float;
use polars_arrow::kernels::float::*;
use polars_arrow::kernels::set::set_at_nulls;
impl<T> ChunkedArray<T>
where
T: PolarsFloatType,
T::Native: Float,
{
pub fn is_nan(&self) -> BooleanChunked {
self.apply_kernel_cast(&is_nan::<T::Native>)
}
pub fn is_not_nan(&self) -> BooleanChunked {
self.apply_kernel_cast(&is_not_nan::<T::Native>)
}
pub fn is_finite(&self) -> BooleanChunked {
self.apply_kernel_cast(&is_finite)
}
pub fn is_infinite(&self) -> BooleanChunked {
self.apply_kernel_cast(&is_infinite)
}
#[must_use]
pub fn none_to_nan(&self) -> Self {
let chunks = self
.downcast_iter()
.map(|arr| Arc::new(set_at_nulls(arr, T::Native::nan())) as ArrayRef)
.collect();
ChunkedArray::from_chunks(self.name(), chunks)
}
}