Skip to content

Commit c597428

Browse files
committed
remove action=ignore for .apply() on cat dtype
1 parent 139def2 commit c597428

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ Other Removals
490490
- Removed the ``method`` keyword in ``ExtensionArray.fillna``, implement ``ExtensionArray._pad_or_backfill`` instead (:issue:`53621`)
491491
- Removed the attribute ``dtypes`` from :class:`.DataFrameGroupBy` (:issue:`51997`)
492492
- Enforced deprecation of ``argmin``, ``argmax``, ``idxmin``, and ``idxmax`` returning a result when ``skipna=False`` and an NA value is encountered or all values are NA values; these operations will now raise in such cases (:issue:`33941`, :issue:`51276`)
493+
- Removed support for ``action="ignore"`` for :class:`SeriesApply` in :meth:`SeriesApply.apply_standard`, categorical NA value now returns ``False`` (:issue:`59938`)
493494

494495
.. ---------------------------------------------------------------------------
495496
.. _whatsnew_300.performance:

pandas/core/apply.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838
is_numeric_dtype,
3939
is_sequence,
4040
)
41-
from pandas.core.dtypes.dtypes import (
42-
CategoricalDtype,
43-
ExtensionDtype,
44-
)
41+
from pandas.core.dtypes.dtypes import ExtensionDtype
4542
from pandas.core.dtypes.generic import (
4643
ABCDataFrame,
4744
ABCNDFrame,
@@ -1466,13 +1463,10 @@ def curried(x):
14661463
else:
14671464
curried = func
14681465

1469-
# row-wise access
1470-
# apply doesn't have a `na_action` keyword and for backward compat reasons
1471-
# we need to give `na_action="ignore"` for categorical data.
1472-
# TODO: remove the `na_action="ignore"` when that default has been changed in
1466+
# remove the `na_action="ignore"` as default has been changed in
14731467
# Categorical (GH51645).
1474-
action = "ignore" if isinstance(obj.dtype, CategoricalDtype) else None
1475-
mapped = obj._map_values(mapper=curried, na_action=action)
1468+
# Reference for below fix (GH )
1469+
mapped = obj._map_values(mapper=curried)
14761470

14771471
if len(mapped) and isinstance(mapped[0], ABCSeries):
14781472
# GH#43986 Need to do list(mapped) in order to get treated as nested

pandas/tests/apply/test_frame_apply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ def test_apply_category_equalness(val):
741741

742742
result = df.a.apply(lambda x: x == val)
743743
expected = Series(
744-
[np.nan if pd.isnull(x) else x == val for x in df_values], name="a"
744+
[False if pd.isnull(x) else x == val for x in df_values], name="a"
745745
)
746746
tm.assert_series_equal(result, expected)
747747

0 commit comments

Comments
 (0)