Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ Other Deprecations
- 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`)
- 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`)
- Deprecated :meth:`PeriodIndex.astype` to ``datetime64[ns]`` or ``DatetimeTZDtype``, use ``obj.to_timestamp(how).tz_localize(dtype.tz)`` instead (:issue:`44398`)
- Deprecated passing ``skipna=None`` for :meth:`DataFrame.mad` and :meth:`Series.mad`, pass ``skipna=True`` instead (:issue:`44580`)
- Deprecated :meth:`DateOffset.apply`, use ``offset + other`` instead (:issue:`44522`)
-

Expand Down
15 changes: 11 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10579,15 +10579,15 @@ def prod(

product = prod

def mad(self, axis=None, skipna=None, level=None):
def mad(self, axis=None, skipna=True, level=None):
"""
{desc}

Parameters
----------
axis : {axis_descr}
Axis for the function to be applied on.
skipna : bool, default None
skipna : bool, default True
Exclude NA/null values when computing the result.
level : int or level name, default None
If the axis is a MultiIndex (hierarchical), count along a
Expand All @@ -10599,7 +10599,14 @@ def mad(self, axis=None, skipna=None, level=None):
{see_also}\
{examples}
"""
if skipna is None:
if not is_bool(skipna):
warnings.warn(
"Passing None for skipna is deprecated and will raise in a future"
"version. Pass True instead. Only boolean values will be allowed "
"in the future.",
FutureWarning,
stacklevel=find_stack_level(),
)
skipna = True
if axis is None:
axis = self._stat_axis_number
Expand Down Expand Up @@ -10669,7 +10676,7 @@ def all(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs):
see_also="",
examples="",
)
def mad(self, axis=None, skipna=None, level=None):
def mad(self, axis=None, skipna=True, level=None):
return NDFrame.mad(self, axis, skipna, level)

setattr(cls, "mad", mad)
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/frame/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,12 @@ def test_frame_any_with_timedelta(self):
expected = Series(data=[False, True])
tm.assert_series_equal(result, expected)

def test_reductions_deprecation_skipna_none(self, frame_or_series):
# GH#44580
obj = frame_or_series([1, 2, 3])
with tm.assert_produces_warning(FutureWarning, match="skipna"):
obj.mad(skipna=None)

@pytest.mark.parametrize(
"func",
[
Expand Down