diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index c29b61c9eb448..d38ee7b8b589a 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -257,6 +257,8 @@ Deprecations - Deprecated the ``units=M`` (months) and ``units=Y`` (year) parameters for ``units`` of :func:`pandas.to_timedelta`, :func:`pandas.Timedelta` and :func:`pandas.TimedeltaIndex` (:issue:`16344`) - The functions :func:`pandas.to_datetime` and :func:`pandas.to_timedelta` have deprecated the ``box`` keyword. Instead, use :meth:`to_numpy` or :meth:`Timestamp.to_datetime64` or :meth:`Timedelta.to_timedelta64`. (:issue:`24416`) +- The :meth:`DataFrame.compound` and :meth:`Series.compound` methods are deprecated and will be removed in a future version. + .. _whatsnew_0250.prior_deprecations: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 876465d96e6fe..4999153207395 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10177,11 +10177,14 @@ def mad(self, axis=None, skipna=None, level=None): nanops.nanstd) @Substitution(desc="Return the compound percentage of the values for " - "the requested axis.", name1=name, name2=name2, - axis_descr=axis_descr, + "the requested axis.\n\n.. deprecated:: 0.25.0", + name1=name, name2=name2, axis_descr=axis_descr, min_count='', see_also='', examples='') @Appender(_num_doc) def compound(self, axis=None, skipna=None, level=None): + msg = ("The 'compound' method is deprecated and will be" + "removed in a future version.") + warnings.warn(msg, FutureWarning, stacklevel=2) if skipna is None: skipna = True return (1 + self).prod(axis=axis, skipna=skipna, level=level) - 1 diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 52a9f8ac7d722..ef6dca8d2729d 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -1145,6 +1145,15 @@ def test_validate_stat_keepdims(self): with pytest.raises(ValueError, match=msg): np.sum(s, keepdims=True) + def test_compound_deprecated(self): + s = Series([.1, .2, .3, .4]) + with tm.assert_produces_warning(FutureWarning): + s.compound() + + df = pd.DataFrame({'s': s}) + with tm.assert_produces_warning(FutureWarning): + df.compound() + main_dtypes = [ 'datetime',