Skip to content

CategoricalAccessor.categorical removed in 0.24.0rc1 #24751

Closed
@TomAugspurger

Description

@TomAugspurger

Previously, CategoricalAccessor set .categorical in __init__. I don't think this was intended to be the way to access things like .ordered, but it wasn't prefixed with an underscore, so we should deprecate before removing

0.23.4

In [11]: pd.Series(['a', 'b'], dtype='category').cat.categorical.ordered
Out[11]: False

0.24.0rc1

In [3]: pd.Series(['a', 'b'], dtype='category').cat.categorical.ordered
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-e5c7f0300480> in <module>
----> 1 pd.Series(['a', 'b'], dtype='category').cat.categorical.ordered

AttributeError: 'CategoricalAccessor' object has no attribute 'categorical'

We can deprecate with

def categorical(self):
    warnings.warn(...)
    return self._parent

in

class CategoricalAccessor(PandasDelegate, PandasObject, NoNewAttributesMixin):

We should do the same for .index and .name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BlockerBlocking issue or pull request for an upcoming releaseCategoricalCategorical Data TypeDependenciesRequired and optional dependenciesgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions