Open
Description
In Pandas 2.1, Series.map
with the parameter na_ignore
set to na_ignore="ignore"
will work for all array types. (see #51809 + the various PRs that add na_action="ignore"
to the various ExtensionArrays). Previously the support for na_action="ignore"
was quite spotty.
IMO na_action="ignore"
is a better default value than na_action=None
(the current default), because 99 % of the time when I use .map
, I want it to ignore Nans and assume it’s the same for others. E.g.:
>>> import numpy as np
>>> import pandas as pd
>>> ser = pd.Series(["a", np.nan, "b"])
>>> ser.map(str.upper)
TypeError: descriptor 'upper' for 'str' objects doesn't apply to a 'float' object
>>> ser.map(str.upper, na_action="ignore")
0 A
1 NaN
2 B
dtype: object
So I propose deprecating None
as the default for na_action
in favor of "ignore"
.