Polars-ds

raw JSON →
0.11.2 verified Fri May 01 auth: no python

A Python extension for Polars that adds extra data structures and algorithms (e.g., graph, set operations, linear algebra) as expressions and series. Version 0.11.2, released on PyPI, actively maintained with frequent updates.

pip install polars-ds
error ImportError: cannot import name 'Graph' from 'polars_ds'
cause Graph is in submodule polars_ds.graph, not top-level.
fix
Use: from polars_ds.graph import Graph
error AttributeError: 'Expr' object has no attribute 'l1_normalize'
cause Did not import polars_ds.ext before calling extension methods.
fix
Add 'import polars_ds.ext' before using extension expressions.
error TypeError: 'Expr' object is not callable
cause Incorrect syntax: tried to call extension method directly on column, e.g., pl.col('a').l1_normalize() without importing ext.
fix
Either use pds.col('a').l1_normalize() after importing polars_ds.ext, or apply via df.select(pds.col('a').l1_normalize()).
error ModuleNotFoundError: No module named 'polars_ds'
cause Library not installed or installed in wrong environment.
fix
Run: pip install polars-ds
gotcha polars_ds.ext must be imported explicitly to use expression extensions; just importing polars_ds does not register them.
fix Add 'import polars_ds.ext' to your code.
deprecated The 'polars_ds.graph.Graph' class API changed in v0.9.0; old methods like 'graph.nodes()' now return a Polars expression instead of a list.
fix Update to use new expression-based API; refer to migration guide in docs.
breaking In v0.10.0, 'polars_ds.ext' moved from a module to a subpackage; imports like 'from polars_ds.ext import l1_normalize' no longer work. Use 'import polars_ds.ext as pds' then 'pds.l1_normalize'.
fix Change import to 'import polars_ds.ext as pds'.
gotcha polars-ds requires Polars 0.20.x or newer; using older Polars leads to import errors or missing symbols.
fix Upgrade Polars: pip install 'polars>=0.20.0'

Compute L1 normalization on column 'a' using polars-ds extended expressions.

import polars as pl
import polars_ds.ext as pds
df = pl.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
result = df.select(pds.col('a').l1_normalize())
print(result)