Skip to content

Commit b30a19c

Browse files
authored
Deprecate skipna=None for mad (#44580)
1 parent c7d0933 commit b30a19c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

doc/source/whatsnew/v1.4.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ Other Deprecations
465465
- Deprecated casting behavior when passing an item with mismatched-timezone to :meth:`DatetimeIndex.insert`, :meth:`DatetimeIndex.putmask`, :meth:`DatetimeIndex.where` :meth:`DatetimeIndex.fillna`, :meth:`Series.mask`, :meth:`Series.where`, :meth:`Series.fillna`, :meth:`Series.shift`, :meth:`Series.replace`, :meth:`Series.reindex` (and :class:`DataFrame` column analogues). In the past this has cast to object dtype. In a future version, these will cast the passed item to the index or series's timezone (:issue:`37605`)
466466
- Deprecated the 'errors' keyword argument in :meth:`Series.where`, :meth:`DataFrame.where`, :meth:`Series.mask`, and meth:`DataFrame.mask`; in a future version the argument will be removed (:issue:`44294`)
467467
- Deprecated :meth:`PeriodIndex.astype` to ``datetime64[ns]`` or ``DatetimeTZDtype``, use ``obj.to_timestamp(how).tz_localize(dtype.tz)`` instead (:issue:`44398`)
468+
- Deprecated passing ``skipna=None`` for :meth:`DataFrame.mad` and :meth:`Series.mad`, pass ``skipna=True`` instead (:issue:`44580`)
468469
- Deprecated :meth:`DateOffset.apply`, use ``offset + other`` instead (:issue:`44522`)
469470
- A deprecation warning is now shown for :meth:`DataFrame.to_latex` indicating the arguments signature may change and emulate more the arguments to :meth:`.Styler.to_latex` in future versions (:issue:`44411`)
470471
-

pandas/core/generic.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -10597,15 +10597,15 @@ def prod(
1059710597

1059810598
product = prod
1059910599

10600-
def mad(self, axis=None, skipna=None, level=None):
10600+
def mad(self, axis=None, skipna=True, level=None):
1060110601
"""
1060210602
{desc}
1060310603
1060410604
Parameters
1060510605
----------
1060610606
axis : {axis_descr}
1060710607
Axis for the function to be applied on.
10608-
skipna : bool, default None
10608+
skipna : bool, default True
1060910609
Exclude NA/null values when computing the result.
1061010610
level : int or level name, default None
1061110611
If the axis is a MultiIndex (hierarchical), count along a
@@ -10617,7 +10617,14 @@ def mad(self, axis=None, skipna=None, level=None):
1061710617
{see_also}\
1061810618
{examples}
1061910619
"""
10620-
if skipna is None:
10620+
if not is_bool(skipna):
10621+
warnings.warn(
10622+
"Passing None for skipna is deprecated and will raise in a future"
10623+
"version. Pass True instead. Only boolean values will be allowed "
10624+
"in the future.",
10625+
FutureWarning,
10626+
stacklevel=find_stack_level(),
10627+
)
1062110628
skipna = True
1062210629
if axis is None:
1062310630
axis = self._stat_axis_number

pandas/tests/frame/test_reductions.py

+6
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,12 @@ def test_frame_any_with_timedelta(self):
14781478
expected = Series(data=[False, True])
14791479
tm.assert_series_equal(result, expected)
14801480

1481+
def test_reductions_deprecation_skipna_none(self, frame_or_series):
1482+
# GH#44580
1483+
obj = frame_or_series([1, 2, 3])
1484+
with tm.assert_produces_warning(FutureWarning, match="skipna"):
1485+
obj.mad(skipna=None)
1486+
14811487
def test_reductions_deprecation_level_argument(
14821488
self, frame_or_series, reduction_functions
14831489
):

0 commit comments

Comments
 (0)