polars-ops 0.54.4

More operations on Polars data structures
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use polars_core::prelude::StringChunked;
use polars_core::prelude::arity::unary_elementwise;
use unicode_reverse::reverse_grapheme_clusters_in_place;

fn to_reverse_helper(s: Option<&str>) -> Option<String> {
    s.map(|v| {
        let mut text = v.to_string();
        reverse_grapheme_clusters_in_place(&mut text);
        text
    })
}

pub fn reverse(ca: &StringChunked) -> StringChunked {
    unary_elementwise(ca, to_reverse_helper)
}