Skip to content

API: Replace na_action parameter in Series/DataFrame/Index.map by the standard skipna #61530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Making the deprecated example not be runnable since it warns now
  • Loading branch information
datapythonista committed Jun 2, 2025
commit aaf91f7fa4a1757a1be6d340e460a95a8843beb0
29 changes: 20 additions & 9 deletions doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,26 @@ and ``na_action="ignore"`` did not work correctly for any :class:`.ExtensionArra

*New behavior*:

.. ipython:: python
:okwarning:

ser = pd.Series(["a", "b", np.nan], dtype="category")
ser.map(str.upper, na_action="ignore")
df = pd.DataFrame(ser)
df.map(str.upper, na_action="ignore")
idx = pd.Index(ser)
idx.map(str.upper, na_action="ignore")
.. code-block:: ipython

In [1]: ser = pd.Series(["a", "b", np.nan], dtype="category")
In [2]: ser.map(str.upper, na_action="ignore")
Out[2]:
0 A
1 B
2 NaN
dtype: category
Categories (2, object): ['A', 'B']
In [3]: df = pd.DataFrame(ser)
In [4]: df.map(str.upper, na_action="ignore")
Out[4]:
0
0 A
1 B
2 NaN
In [5]: idx = pd.Index(ser)
In [6]: idx.map(str.upper, na_action="ignore")
Out[6]: CategoricalIndex(['A', 'B', nan], categories=['A', 'B'], ordered=False, dtype='category')

Also, note that :meth:`Categorical.map` implicitly has had its ``na_action`` set to ``"ignore"`` by default.
This has been deprecated and the default for :meth:`Categorical.map` will change
Expand Down