1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use super::*;
use crate::chunked_array::ops::append::new_chunks;
impl CategoricalChunked {
pub fn append(&mut self, other: &Self) -> Result<()> {
let (rev_map_l, rev_map_r) = (self.get_rev_map(), other.get_rev_map());
if !rev_map_l.same_src(rev_map_r) && !Arc::ptr_eq(rev_map_l, rev_map_r) {
return Err(PolarsError::ComputeError(
"Appending categorical data can only be done if they are made under the same global string cache. \
Consider using a global string cache.".into()
));
}
let new_rev_map = self.merge_categorical_map(other);
self.set_rev_map(new_rev_map, false);
let len = self.len();
new_chunks(&mut self.logical.chunks, &other.logical().chunks, len);
Ok(())
}
}