Skip to content
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

Deprecate skipna=None for mad #44580

Merged
merged 5 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -465,6 +465,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`)
- 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`)
-
Expand Down
13 changes: 10 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10597,15 +10597,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 @@ -10617,7 +10617,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 "
mroeschke marked this conversation as resolved.
Show resolved Hide resolved
"in the future.",
FutureWarning,
stacklevel=find_stack_level(),
)
skipna = True
if axis is None:
axis = self._stat_axis_number
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)

def test_reductions_deprecation_level_argument(
self, frame_or_series, reduction_functions
):
Expand Down