pola-rs/polars · error · AttributeRemovedError
` ` was removed in version 2.0;
Error message
`{name}` was removed in version 2.0; {removed[name]} What it means
Accessing a function that was removed in polars 2.0 (e.g. `read_csv_batched`, `threadpool_size`, `arctan2d`) raises `AttributeRemovedError` with a replacement hint from a hard-coded `removed` dict in `__getattr__`. The library maps each removed name to a concrete migration instruction and fails immediately so stale call sites are found.
Solutions
- Follow the per-name hint: use `thread_pool_size`, `scan_csv` with streaming collection, `arctan2` plus `.degrees()`, or group_by with row index.
- Read the polars 2.0 migration guide and update all removed call sites.
- Pin polars <2.0 only as a temporary stopgap while migrating.
Example fix
// before size = polars.threadpool_size() // after size = polars.thread_pool_size()
Defensive patterns
Strategy: validation
Validate before calling
assert not hasattr(polars, 'read_csv_batched'), 'update to scan_csv'
Try / catch
try:
size = polars.threadpool_size()
except AttributeError:
size = polars.thread_pool_size() Prevention
- Read the major-version changelog before bumping polars across 2.0.
- Run your test suite against the new major version in CI before merging the upgrade.
- Replace removed APIs (read_csv_batched, threadpool_size, arctan2d, groups) proactively on 1.x.
When it happens
Trigger: Calling `polars.read_csv_batched`, `polars.threadpool_size`, `polars.arctan2d`, or `DataFrame.groups` on polars >= 2.0 (names present in the removed dict).
Common situations: Skipping major-version migration; long-lived internal scripts updated rarely; code relying on renamed APIs like threadpool_size vs thread_pool_size.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- accessing ` ` from the top-level `polars` module was…
- altair>=5.4.0 is required for `.plot`
- `arctan2` expected a `str` or `Expr` got a
- `arctan2` expected a `str` or `Expr` got a
- arr.dot query vector must be one-dimensional
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/b6f2245b572289dd.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/__init__.py:554
import polars.datatypes.group as dtgroup
if name in dir(dtgroup):
msg = (
f"`{name}` was deprecated in version 1.0.0. Define your own data type groups or "
"use the `polars.selectors` module for selecting columns of a certain data type."
)
raise exceptions.AttributeRemovedError(msg)
# Functions removed in 2.0
removed = {
"arctan2d": "use `arctan2` followed by `.degrees()` instead.",
"groups": "use `df.with_row_index().group_by(...).agg(pl.col('index'))` instead.",
"read_csv_batched": "use `scan_csv` instead, in conjunction with `LazyFrame.collect(engine='streaming')`.",
"threadpool_size": "it was renamed; use `thread_pool_size` instead.",
}
if name in removed:
msg = f"`{name}` was removed in version 2.0; {removed[name]}"
raise exceptions.AttributeRemovedError(msg)
msg = f"module {__name__!r} has no attribute {name!r}"
raise AttributeError(msg)
View on GitHub (pinned to fe841f959e)