Skip to content

Commit 421ae9d

Browse files
DEPR: deprecate Series/DataFrame.compound (#26405)
1 parent 9c5165e commit 421ae9d

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

doc/source/whatsnew/v0.25.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ Deprecations
257257

258258
- 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`)
259259
- 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`)
260+
- The :meth:`DataFrame.compound` and :meth:`Series.compound` methods are deprecated and will be removed in a future version.
261+
260262

261263
.. _whatsnew_0250.prior_deprecations:
262264

pandas/core/generic.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -10177,11 +10177,14 @@ def mad(self, axis=None, skipna=None, level=None):
1017710177
nanops.nanstd)
1017810178

1017910179
@Substitution(desc="Return the compound percentage of the values for "
10180-
"the requested axis.", name1=name, name2=name2,
10181-
axis_descr=axis_descr,
10180+
"the requested axis.\n\n.. deprecated:: 0.25.0",
10181+
name1=name, name2=name2, axis_descr=axis_descr,
1018210182
min_count='', see_also='', examples='')
1018310183
@Appender(_num_doc)
1018410184
def compound(self, axis=None, skipna=None, level=None):
10185+
msg = ("The 'compound' method is deprecated and will be"
10186+
"removed in a future version.")
10187+
warnings.warn(msg, FutureWarning, stacklevel=2)
1018510188
if skipna is None:
1018610189
skipna = True
1018710190
return (1 + self).prod(axis=axis, skipna=skipna, level=level) - 1

pandas/tests/series/test_analytics.py

+9
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,15 @@ def test_validate_stat_keepdims(self):
11451145
with pytest.raises(ValueError, match=msg):
11461146
np.sum(s, keepdims=True)
11471147

1148+
def test_compound_deprecated(self):
1149+
s = Series([.1, .2, .3, .4])
1150+
with tm.assert_produces_warning(FutureWarning):
1151+
s.compound()
1152+
1153+
df = pd.DataFrame({'s': s})
1154+
with tm.assert_produces_warning(FutureWarning):
1155+
df.compound()
1156+
11481157

11491158
main_dtypes = [
11501159
'datetime',

0 commit comments

Comments
 (0)