Skip to content

Commit d9e955e

Browse files
committed
remove code for ptp()
1 parent d89d7f6 commit d9e955e

File tree

3 files changed

+68
-68
lines changed

3 files changed

+68
-68
lines changed

pandas/core/generic.py

+36-36
Original file line numberDiff line numberDiff line change
@@ -10184,42 +10184,42 @@ def mad(self, axis=None, skipna=None, level=None):
1018410184
_min_examples,
1018510185
)
1018610186

10187-
@classmethod
10188-
def _add_series_only_operations(cls):
10189-
"""
10190-
Add the series only operations to the cls; evaluate the doc
10191-
strings again.
10192-
"""
10193-
10194-
axis_descr, name, name2 = _doc_parms(cls)
10195-
10196-
def nanptp(values, axis=0, skipna=True):
10197-
nmax = nanops.nanmax(values, axis, skipna)
10198-
nmin = nanops.nanmin(values, axis, skipna)
10199-
warnings.warn(
10200-
"Method .ptp is deprecated and will be removed "
10201-
"in a future version. Use numpy.ptp instead."
10202-
"if you are already using numpy.ptp and still getting this message,"
10203-
"please call to_numpy() to avoid this message in future calls."
10204-
"For example: np.ptp(pd.Series([1, 2, 3]).to_numpy())",
10205-
FutureWarning,
10206-
stacklevel=4,
10207-
)
10208-
return nmax - nmin
10209-
10210-
cls.ptp = _make_stat_function(
10211-
cls,
10212-
"ptp",
10213-
name,
10214-
name2,
10215-
axis_descr,
10216-
"""Return the difference between the min and max value.
10217-
\n.. deprecated:: 0.24.0 Use numpy.ptp instead
10218-
\nReturn the difference between the maximum value and the
10219-
minimum value in the object. This is the equivalent of the
10220-
``numpy.ndarray`` method ``ptp``.""",
10221-
nanptp,
10222-
)
10187+
# @classmethod
10188+
# def _add_series_only_operations(cls):
10189+
# """
10190+
# Add the series only operations to the cls; evaluate the doc
10191+
# strings again.
10192+
# """
10193+
10194+
# axis_descr, name, name2 = _doc_parms(cls)
10195+
10196+
# def nanptp(values, axis=0, skipna=True):
10197+
# nmax = nanops.nanmax(values, axis, skipna)
10198+
# nmin = nanops.nanmin(values, axis, skipna)
10199+
# warnings.warn(
10200+
# "Method .ptp is deprecated and will be removed "
10201+
# "in a future version. Use numpy.ptp instead."
10202+
# "if you are already using numpy.ptp and still getting this message,"
10203+
# "please call to_numpy() to avoid this message in future calls."
10204+
# "For example: np.ptp(pd.Series([1, 2, 3]).to_numpy())",
10205+
# FutureWarning,
10206+
# stacklevel=4,
10207+
# )
10208+
# return nmax - nmin
10209+
10210+
# cls.ptp = _make_stat_function(
10211+
# cls,
10212+
# "ptp",
10213+
# name,
10214+
# name2,
10215+
# axis_descr,
10216+
# """Return the difference between the min and max value.
10217+
# \n.. deprecated:: 0.24.0 Use numpy.ptp instead
10218+
# \nReturn the difference between the maximum value and the
10219+
# minimum value in the object. This is the equivalent of the
10220+
# ``numpy.ndarray`` method ``ptp``.""",
10221+
# nanptp,
10222+
# )
1022310223

1022410224
@classmethod
1022510225
def _add_series_or_dataframe_operations(cls):

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4390,7 +4390,7 @@ def to_period(self, freq=None, copy=True):
43904390
["index"], docs={"index": "The index (axis labels) of the Series."},
43914391
)
43924392
Series._add_numeric_operations()
4393-
Series._add_series_only_operations()
4393+
# Series._add_series_only_operations()
43944394
Series._add_series_or_dataframe_operations()
43954395

43964396
# Add arithmetic!

pandas/tests/series/test_analytics.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -861,37 +861,37 @@ def test_ptp(self):
861861
assert np.ptp(ser) == np.ptp(arr)
862862

863863
# GH11163
864-
s = Series([3, 5, np.nan, -3, 10])
865-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
866-
assert s.ptp() == 13
867-
assert pd.isna(s.ptp(skipna=False))
868-
869-
mi = pd.MultiIndex.from_product([["a", "b"], [1, 2, 3]])
870-
s = pd.Series([1, np.nan, 7, 3, 5, np.nan], index=mi)
871-
872-
expected = pd.Series([6, 2], index=["a", "b"], dtype=np.float64)
873-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
874-
tm.assert_series_equal(s.ptp(level=0), expected)
875-
876-
expected = pd.Series([np.nan, np.nan], index=["a", "b"])
877-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
878-
tm.assert_series_equal(s.ptp(level=0, skipna=False), expected)
879-
880-
msg = "No axis named 1 for object type <class 'pandas.core.series.Series'>"
881-
with pytest.raises(ValueError, match=msg):
882-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
883-
s.ptp(axis=1)
884-
885-
s = pd.Series(["a", "b", "c", "d", "e"])
886-
msg = r"unsupported operand type\(s\) for -: 'str' and 'str'"
887-
with pytest.raises(TypeError, match=msg):
888-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
889-
s.ptp()
890-
891-
msg = r"Series\.ptp does not implement numeric_only\."
892-
with pytest.raises(NotImplementedError, match=msg):
893-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
894-
s.ptp(numeric_only=True)
864+
# s = Series([3, 5, np.nan, -3, 10])
865+
# with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
866+
# assert s.ptp() == 13
867+
# assert pd.isna(s.ptp(skipna=False))
868+
869+
# mi = pd.MultiIndex.from_product([["a", "b"], [1, 2, 3]])
870+
# s = pd.Series([1, np.nan, 7, 3, 5, np.nan], index=mi)
871+
872+
# expected = pd.Series([6, 2], index=["a", "b"], dtype=np.float64)
873+
# with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
874+
# tm.assert_series_equal(s.ptp(level=0), expected)
875+
876+
# expected = pd.Series([np.nan, np.nan], index=["a", "b"])
877+
# with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
878+
# tm.assert_series_equal(s.ptp(level=0, skipna=False), expected)
879+
880+
# msg = "No axis named 1 for object type <class 'pandas.core.series.Series'>"
881+
# with pytest.raises(ValueError, match=msg):
882+
# with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
883+
# s.ptp(axis=1)
884+
885+
# s = pd.Series(["a", "b", "c", "d", "e"])
886+
# msg = r"unsupported operand type\(s\) for -: 'str' and 'str'"
887+
# with pytest.raises(TypeError, match=msg):
888+
# with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
889+
# s.ptp()
890+
891+
# msg = r"Series\.ptp does not implement numeric_only\."
892+
# with pytest.raises(NotImplementedError, match=msg):
893+
# with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
894+
# s.ptp(numeric_only=True)
895895

896896
def test_repeat(self):
897897
s = Series(np.random.randn(3), index=["a", "b", "c"])

0 commit comments

Comments
 (0)