polars_plan/dsl/
cat.rs

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
34
35
36
37
38
39
use super::*;

/// Specialized expressions for Categorical dtypes.
pub struct CategoricalNameSpace(pub(crate) Expr);

impl CategoricalNameSpace {
    pub fn get_categories(self) -> Expr {
        self.0
            .apply_private(CategoricalFunction::GetCategories.into())
    }

    #[cfg(feature = "strings")]
    pub fn len_bytes(self) -> Expr {
        self.0
            .map_private(FunctionExpr::Categorical(CategoricalFunction::LenBytes))
    }

    #[cfg(feature = "strings")]
    pub fn len_chars(self) -> Expr {
        self.0
            .map_private(FunctionExpr::Categorical(CategoricalFunction::LenChars))
    }

    #[cfg(feature = "strings")]
    pub fn starts_with(self, prefix: String) -> Expr {
        self.0
            .map_private(FunctionExpr::Categorical(CategoricalFunction::StartsWith(
                prefix,
            )))
    }

    #[cfg(feature = "strings")]
    pub fn ends_with(self, suffix: String) -> Expr {
        self.0
            .map_private(FunctionExpr::Categorical(CategoricalFunction::EndsWith(
                suffix,
            )))
    }
}