pola-rs/polars · error · AttributeRemovedError

` ` was removed in version ;

Error message

`{name}` was removed in version {version}; {hint}

What it means

Polars raises AttributeRemovedError (an AttributeError subclass) when code accesses an attribute that existed in an older Polars version and was explicitly removed. `raise_for_removed_attributes` looks the name up in a registry of removed attributes and includes the removal version and an optional migration hint.

Solutions

  1. Use the migration hint to find the replacement attribute/method
  2. Consult the Polars changelog for the removal version
  3. Update the calling code to the new API name

Example fix

// before
df.columns0  # removed attribute
// after
df.columns[0]
Defensive patterns

Strategy: try-catch

Validate before calling

if hasattr(df, "removed_attr"):
    value = df.removed_attr
else:
    value = df.replacement_attr

Try / catch

try:
    value = obj.removed_attr
except AttributeError as e:
    print(e)  # includes version and migration hint
    value = obj.replacement_attr

Prevention

When it happens

Trigger: Accessing a removed attribute such as `df.get_columns`-style legacy names, e.g. `series.<old_attr>` or `pl.<old_attr>` after upgrading past the removal version.

Common situations: Upgrading Polars across a major change; running old notebooks/scripts; libraries built on Polars that still reference removed attributes.

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


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/b9d615dd3e3dc98b. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/_utils/expired.py:62

    """
    Raise an `AttributeError` for a removed attribute.

    Parameters
    ----------
    obj
        The object from which the attribute was removed.
    name
        The name of the removed attribute.
    attributes
        A dictionary mapping removed attribute names to hints for replacement.
    version
        The version in which the attribute was removed.
    """
    if name in attributes:
        hint = attributes[name]
        msg = f"`{name}` was removed in version {version}"
        msg = f"{msg}." if hint is None else f"{msg}; {hint}"
        raise AttributeRemovedError(msg, name=name, obj=obj)


def getattr_fallback(
    obj: object, superclass: object, name: str, *, meta: bool = False
) -> Any:
    """
    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).

View on GitHub (pinned to fe841f959e)