-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
DEPR: Series[categorical].replace special-casing #56385
Conversation
@@ -473,6 +473,7 @@ Other Deprecations | |||
- Deprecated the ``kind`` keyword in :meth:`Series.resample` and :meth:`DataFrame.resample`, explicitly cast the object's ``index`` instead (:issue:`55895`) | |||
- Deprecated the ``ordinal`` keyword in :class:`PeriodIndex`, use :meth:`PeriodIndex.from_ordinals` instead (:issue:`55960`) | |||
- Deprecated the ``unit`` keyword in :class:`TimedeltaIndex` construction, use :func:`to_timedelta` instead (:issue:`55499`) | |||
- Deprecated the behavior of :meth:`DataFrame.replace` and :meth:`Series.replace` with :class:`CategoricalDtype`; in a future version replace will change the values while preserving the categories. To change the categories, use ``ser.cat.rename_categories`` instead (:issue:`55147`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious. If one does Categorical[int].replace(1, 1.2)
in the future will that case raise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will behave like ser[ser == 1] = 1.2
, which raises TypeError: Cannot setitem on a Categorical with a new category (1.2), set the categories first
Thanks @jbrockmendel |
Is there any use case for categorical replace now? I guess not? Except if you try to replace non-existing values? |
Matches pandas 2.2 behavior: pandas-dev/pandas#56385 Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - Michael Wang (https://github.com/isVoid) URL: #14988
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.