You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Categorical nan value is hard-coded to np.nan. I propose making the CategoricalDtype.na_value take its value from CategoricalDtype.categories.dtype.na_value if the categories is an ExtensionArray else fall back to np.nan.
There are various code parts in Categorical that presume that the nan sentinel value is np.nan. Those will have to be changed to use Categorical.dtype.na_value instead.
The text was updated successfully, but these errors were encountered:
topper-123
changed the title
API: Add na_value to CategoricalDtype
API: use na_value from.categories in CategoricalDtype
Apr 16, 2023
topper-123
changed the title
API: use na_value from.categories in CategoricalDtype
API: use na_value from CategoricalDtype.categories in Categorical
Apr 16, 2023
Yes, it's the same idea is mentioned by @jorisvandenbossche. I think that's also the final conclusion for #50711 (i.e to follow the nan-behaviour of the underlying categories (np.nan for numpy arrays, pd.NA for extensionarrays).
Currently, the
Categorical
nan value is hard-coded tonp.nan
. I propose making theCategoricalDtype.na_value
take its value fromCategoricalDtype.categories.dtype.na_value
if the categories is anExtensionArray
else fall back tonp.nan
.There are various code parts in
Categorical
that presume that the nan sentinel value isnp.nan
. Those will have to be changed to useCategorical.dtype.na_value
instead.The text was updated successfully, but these errors were encountered: