Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/cat.rs
6939 views
1
use super::*;
2
3
/// Specialized expressions for Categorical dtypes.
4
pub struct CategoricalNameSpace(pub(crate) Expr);
5
6
impl CategoricalNameSpace {
7
pub fn get_categories(self) -> Expr {
8
self.0.map_unary(CategoricalFunction::GetCategories)
9
}
10
11
#[cfg(feature = "strings")]
12
pub fn len_bytes(self) -> Expr {
13
self.0.map_unary(CategoricalFunction::LenBytes)
14
}
15
16
#[cfg(feature = "strings")]
17
pub fn len_chars(self) -> Expr {
18
self.0.map_unary(CategoricalFunction::LenChars)
19
}
20
21
#[cfg(feature = "strings")]
22
pub fn starts_with(self, prefix: String) -> Expr {
23
self.0.map_unary(CategoricalFunction::StartsWith(prefix))
24
}
25
26
#[cfg(feature = "strings")]
27
pub fn ends_with(self, suffix: String) -> Expr {
28
self.0.map_unary(CategoricalFunction::EndsWith(suffix))
29
}
30
31
#[cfg(feature = "strings")]
32
pub fn slice(self, offset: i64, length: Option<usize>) -> Expr {
33
self.0.map_unary(CategoricalFunction::Slice(offset, length))
34
}
35
}
36
37