Skip to content

ABCIndex does not recognize Int64Index #17184

Closed
@jbrockmendel

Description

@jbrockmendel

Is this intentional? Is the idea that isinstance(foo, Index) can be replaced by isinstance(foo, ABCIndexClass) and not isinstance(foo, ABCIndex)? Now that I look at it this seems obvious, but still unexpected.

import pandas as pd
idx = pd.Int64Index([1, 2, 1, 1, 1], dtype='int64')

>>> isinstance(idx, pd.core.dtypes.generic.ABCIndex)
False

Checking isinstance(by, ABCIndex) instead of isinstance(by, Index) caused a test failure in #17174.

Possibly related is a comment in pd.core.strings.StringAccessorMixin._make_str_accessor:

        elif isinstance(self, Index):
            # can't use ABCIndex to exclude non-str

I count 6 usages of ABCIndex across the package. Are we sure no one else has made the same mistake I did of using this where ABCIndexClass should have been used?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions