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

DEPR: deprecate Series/DataFrame.compound #26405

Merged
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
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 5 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down