I can get integer representation and revmap of CategoricalChunked.
let s = Series::new("Fruit", ["Apple", "Apple", "Pear"]);
let s_cat = s.cast(&DataType::Categorical(Some(Arc::new(RevMapping::default())))).unwrap();
let s_cat_chunck = s_cat.categorical().unwrap().to_owned(); //CategoricalChunked
let s_logical = s_cat_chunck.logical().to_owned(); // integer representation
let s_revmap = s_cat_chunck.get_rev_map().to_owned(); //revmap
How to create CategoricalChunked from s_logical
and s_revmap
?
Context:
I need to do some operations (mostly comparisons and if else branching based on comparsions) on elements of a CategoricalChunked. The CategoricalChunked is large and there will be very large number of comparisons in my algorithm.
To iterate over CategroicalChunked we have function iter_str()
. But the iterator iterate over &str. My guess is comparisons on &str would be slower. I am thinking of doing comparisons with integer representation (s_logical
) and get result back as categorical.