Skip to content

magarick/tarsiers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tarsiers

Powerful Polars is Terser with Tarsiers

Tarsiers is an add-on to Polars enabling more concise expressions and less typing. It is primarily intended for interactive use where quick iteration and concise code are most valuable.

More symbol-like columns, as it should be! For simply named columns you can write C.foo instead of pl.col("foo").

Symbol-like symbols. Only N for now, but it's a nice feature from data.table to borrow.

>>> import polars as pl
>>> import tarsiers as tr
>>> import tarsiers.col as C
>>> import tarsiers.symbols as S
>>> df = pl.DataFrame({"foo": [1, 3, 4], "bar": [3, 4, 0]})
>>> df.with_columns(
...     tr.cases(C.foo > 2, 1, C.bar > 2, 4, default = -1).alias("val")
... )
shape: (3, 3)
┌─────┬─────┬─────┐
│ foobarval │
│ --------- │
│ i64i64i32 │
╞═════╪═════╪═════╡
│ 134   │
│ 341   │
│ 401   │
└─────┴─────┴─────┘

>>> df.groupby(C.foo % 2 == 1).agg(S.N, S.I, C.bar.sum())
shape: (2, 4)
┌───────┬───────┬───────────┬─────┐
│ foocountidxbar │
│ ------------ │
│ boolu32list[u32] ┆ i64 │
╞═══════╪═══════╪═══════════╪═════╡
│ false1     ┆ [2]       ┆ 0   │
│ true2     ┆ [0, 1]    ┆ 7   │
└───────┴───────┴───────────┴─────┘

About

Powerful Polars is Terser with Tarsiers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages