Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-ops/src/series/ops/not.rs
6939 views
1
use std::ops::Not;
2
3
use polars_core::with_match_physical_integer_polars_type;
4
5
use super::*;
6
7
pub fn negate_bitwise(s: &Series) -> PolarsResult<Series> {
8
match s.dtype() {
9
DataType::Boolean => Ok(s.bool().unwrap().not().into_series()),
10
dt if dt.is_integer() => {
11
with_match_physical_integer_polars_type!(dt, |$T| {
12
let ca: &ChunkedArray<$T> = s.as_any().downcast_ref().unwrap();
13
Ok(ca.apply_values(|v| !v).into_series())
14
})
15
},
16
dt => polars_bail!(InvalidOperation: "dtype {:?} not supported in 'not' operation", dt),
17
}
18
}
19
20