pola-rs/polars · error · AttributeError
{objname} object has no attribute {name!r}
Error message
{objname} object has no attribute {name!r} What it means
Fallback AttributeError raised by polars' getattr_fallback when a missing attribute is looked up on a polars class and no superclass __getattr__ handles it. It is the terminal error after removed-attribute checks have passed, producing the standard 'object has no attribute' message (with quoting adapted for metaclasses).
Source
Thrown at py-polars/src/polars/_utils/expired.py:87
Raise an `AttributeError` for a non-existent attribute.
Parameters
----------
obj
The object on which the attribute was accessed.
superclass
The superclass of the object used to attempt to access the attribute.
name
The name of the non-existent attribute.
meta
Whether the object is a metaclass (default: False).
"""
if (super_getattr := getattr(superclass, "__getattr__", None)) is not None:
return super_getattr(name)
else:
objname = f"{obj.__name__!r}" if meta else f"{type(obj).__name__!r}" # type: ignore[attr-defined]
msg = f"{objname} object has no attribute {name!r}"
raise AttributeError(msg, name=name, obj=obj)
def removed_parameters(
*params: RemovedParameter | RenamedParameter,
) -> IdentityFunction:
"""
Decorator to mark function parameters.
This decorator expects a number of `RemovedParameter` or `RenamedParameter`
instances that describe each of the removed parameters of the method.
"""
assert len(params) == len({p.name for p in params}), (
"duplicate parameter in removed parameter list"
)
params_dict = {p.name: p for p in params}
def decorate(function: Callable[P, T]) -> Callable[P, T]:
@wraps(function)View on GitHub (pinned to 5d8ebabf11)
Solutions
- Check the spelling against the current API docs (e.g. it's columns not coloumns)
- Use dir(obj) or getattr(obj, 'name', default) to introspect available attributes
- Search the migration guide in case the attribute was renamed
- Update IDE stubs/types so autocomplete matches the installed version
Example fix
# before df.coloumns # after df.columns
Defensive patterns
Strategy: type-guard
Validate before calling
valid = [a for a in dir(df) if 'col' in a.lower()]
Type guard
def has_attr(obj: object, name: str) -> bool:
return hasattr(obj, name) or name in dir(obj) Try / catch
try:
val = getattr(obj, name)
except AttributeError as e:
raise AttributeError(f'{name} missing on {type(obj).__name__}: check docs') from e Prevention
- Enable IDE type stubs / mypy with polars plugin
- Use dir(obj) during interactive development
- Avoid copy-pasting attribute names from old tutorials
When it happens
Trigger: Accessing any misspelled or nonexistent attribute on polars classes that install getattr_fallback in their metaclass or __getattr__ chain, e.g. df.coloumns, pl.DataFame, Expr.lst.sum.
Common situations: Typos in attribute names, autocomplete suggestions from outdated tutorials, or code written against a different polars version where the attribute never existed or has a different name.
Related errors
- {type(self).__name__!r} object has no attribute {name!r}
- list.to_struct() got a str instead of a list. hint: pass ['{
- schema_mode='overwrite' requires mode='overwrite'
- `{name}` was removed in version {version}
- {func_name!r} received both {param.name!r} and {param.new_na
AI-assisted analysis of pola-rs/polars@5d8ebabf11 (2026-08-28).
Data as JSON: /api/errors/ef5f12f3a5d71ff8.
Report an issue: GitHub.