Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

:timing
:sccache 1
:dep polars = { version = "0.21.1", features = ["lazy", "parquet"] }
use polars::prelude::*;

ChunkedArray

Series

let s: Series = [10, 20, 30].iter().collect();
s
shape: (3,) Series: '' [i32] [ 10 20 30 ]
s.len()
3
s.get(2)
Int32(30)
match s.get(2) {
    AnyValue::Int32(x) => x,
    _ => panic!(),
}
30

Convert a Series to a ChunkedArray.

{
    let ca = s.i32().unwrap();
    ca
}
shape: (3,) ChunkedArray: '' [Int32] [ 10 20 30 ]

Get the first element of the ChunkedArray.

{
    let ca = s.i32().unwrap();
    ca.get(0)
}
Some(10)