Skip to content

BUG (string dtype): looking up missing value in the Index fails #59879

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

#59765 is the general issue about consistency in index lookups for missing values, but shorter term, we at least need to fix being able to lookup missing values for the future string dtype.

With object dtype, this works fine:

>>> idx = pd.Index(["a", "b", None])
>>> idx.get_loc(None)
2

But when enabling the string dtype, neither None or np.nan work as key:

>>> pd.options.future.infer_string = True
>>> idx = pd.Index(["a", "b", None])
>>> idx.get_loc(None)
...
KeyError: None
>>> idx.get_loc(np.nan)
...
KeyError: nan

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexRelated to the Index class or subclassesStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions