Skip to content

Proper support of nullable dtypes as the Categorical dtype #50711

Open
@Dr-Irv

Description

@Dr-Irv

Now that Categorical depends on ExtensionArray, it makes more sense to return and output pd.NA as a missing value instead of np.nan.

Propose that we announce in 2.0 release that this will change in a future release. Not clear if/how we create a deprecation message here.

Current behavior:

>>> c = pd.Categorical( ["a", "a", "b", "c", "c"], ["a", "b", "c"])
>>> c
['a', 'a', 'b', 'c', 'c']
Categories (3, object): ['a', 'b', 'c']
>>> s = pd.Series(c)
>>> s
0    a
1    a
2    b
3    c
4    c
dtype: category
Categories (3, object): ['a', 'b', 'c']
>>> s.iloc[2] = pd.NA
>>> s.iloc[2]
nan

Metadata

Metadata

Assignees

No one assigned

    Labels

    CategoricalCategorical Data TypeMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolatePDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions