Skip to content

polars/polars-pandas-api-name

Rule polars-pandas-api-name
Pack Polars
Severity error
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

Polars frames expose a different API from pandas. Use the matching Polars method or expression.

df.groupby("x")
df.group_by("x")

Thirteen AttributeError results on Polars DataFrame, LazyFrame, and Series (groupby, merge, apply, loc, iloc, iterrows, fillna, dropna, sort_values, reset_index, set_index, isna, and notna).

Use xpd check --fix --unsafe-fixes to rename direct one-to-one pandas names (groupby, fillna, dropna, sort_values, isna, notna) to their Polars equivalents. Edit other forms by hand.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

Polars 2.1.0 raises AttributeError for groupby. Use group_by instead.

Browse the other rules of the Polars pack.