What's the alternative of pandas :
data['ColumnA'].str[:2]
in rust polars? My first guess was:
let x = Utf8Chunked::new("ColumnA", &["Pear", "apple", "toly", "x"]);
let y = x.slice(0, 2);
I'd like to get an array/ChunkedArray/Utf8Chunked which looks something like ["Pe", "ap", "to", "x"]
. But .slice()
actually just takes first n elements of an array. Is it possible without iterating over the array? (as my understanding iterating would slow down the performance).
Many thanks,