typestar

Series in Python

A Polars Series is a typed, named column backed by Arrow memory.

import polars as pl

runs = pl.Series("tpm", [91, 104, 88])

print(runs.dtype, runs.name, len(runs))
print(runs.mean(), runs.max(), runs.std().__round__(2))
print((runs > 90).to_list())
print(runs.cast(pl.Float64).to_list())

How it works

  1. The dtype is part of the Series, and it is strict.
  2. Arithmetic and comparisons return new Series.
  3. to_list is the escape hatch back to Python objects.

Keywords and builtins used here

The run, in numbers

Lines
8
Characters to type
224
Tokens
89
Three-star pace
100 tpm

At the three-star pace of 100 tokens a minute, this run takes about 53 seconds.

Type this snippet

Step 1 of 4 in Series & frames, step 1 of 32 in Polars.

Next →