Skip to content

Change in behaviour of unique method regarding None values #20866

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

The behaviour of unique regarding None values recently changed on master (somewhere in the last month) :

In [1]: pd.__version__
Out[1]: '0.22.0'

In [2]: s = pd.Series(['test', None])

In [3]: s.unique()
Out[3]: array(['test', None], dtype=object)

vs

In [1]: pd.__version__
Out[1]: '0.23.0.dev0+807.g563a6ad'

In [2]: s = pd.Series(['test', None])

In [3]: s.unique()
Out[3]: array(['test', nan], dtype=object)

Not sure what the desired result is (we typically handle None like it is missing like NaN, but on the other hand, we also didn't coerce to it on construction, i.e. we do allow None values to be stored), but it is a breaking change (discovered it because geopandas tests started failing; geopandas/geopandas#711).

Metadata

Metadata

Assignees

No one assigned

    Labels

    AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffBlockerBlocking issue or pull request for an upcoming releaseDtype ConversionsUnexpected or buggy dtype conversionsRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions