The polars backend for datar — dplyr-style data manipulation in Python, powered by lazy evaluation.
pip install -U datar-polars
# or
pip install -U datar[polars]from datar import f
from datar.dplyr import mutate, filter_, summarise, group_by
from datar.tibble import tibble
df = tibble(
name=["a", "b", "c", "a", "b"],
value=[1, 2, 3, 4, 5],
)
df >> group_by(f.name) >> summarise(total=f.value.sum())
"""# output:
name total
0 a 5
1 b 7
2 c 3
"""
df >> mutate(double=f.value * 2) >> filter_(f.double > 5)
"""# output:
name value double
0 c 3 6
1 a 4 8
2 b 5 10
"""All operations build lazy polars query plans. Computation is deferred until you call .collect() or materialize the result.
| Category | Status |
|---|---|
| Core dplyr (mutate, filter, select, arrange, summarise, joins, etc.) | Done |
| Group-by operations | Done |
| Row-wise operations | Done |
| Slice, reframe, distinct, count | Done |
| tidyr verbs (pivot, nest, fill, separate, etc.) | Done |
| forcats verbs (factor ordering, levels, etc.) | Done |
| base APIs (arithmetic, string, sequence, cumulative) | Done |
| Tibble, enframe, add_column, add_row | Done |