Skip to content

Commit 9ab0404

Browse files
committed
DEPR: remove *args, **kwargs on resample methods
1 parent b3cb116 commit 9ab0404

File tree

2 files changed

+1
-56
lines changed

2 files changed

+1
-56
lines changed

pandas/core/resample.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
TimestampConvertibleTypes,
3838
npt,
3939
)
40-
from pandas.compat.numpy import function as nv
4140
from pandas.errors import (
4241
AbstractMethodError,
4342
DataError,
@@ -899,75 +898,54 @@ def sum(
899898
self,
900899
numeric_only: bool = False,
901900
min_count: int = 0,
902-
*args,
903-
**kwargs,
904901
):
905-
nv.validate_resampler_func("sum", args, kwargs)
906902
return self._downsample("sum", numeric_only=numeric_only, min_count=min_count)
907903

908904
@doc(GroupBy.prod)
909905
def prod(
910906
self,
911907
numeric_only: bool = False,
912908
min_count: int = 0,
913-
*args,
914-
**kwargs,
915909
):
916-
nv.validate_resampler_func("prod", args, kwargs)
917910
return self._downsample("prod", numeric_only=numeric_only, min_count=min_count)
918911

919912
def min(
920913
self,
921914
numeric_only: bool = False,
922915
min_count: int = 0,
923-
*args,
924-
**kwargs,
925916
):
926-
nv.validate_resampler_func("min", args, kwargs)
927917
return self._downsample("min", numeric_only=numeric_only, min_count=min_count)
928918

929919
def max(
930920
self,
931921
numeric_only: bool = False,
932922
min_count: int = 0,
933-
*args,
934-
**kwargs,
935923
):
936-
nv.validate_resampler_func("max", args, kwargs)
937924
return self._downsample("max", numeric_only=numeric_only, min_count=min_count)
938925

939926
@doc(GroupBy.first)
940927
def first(
941928
self,
942929
numeric_only: bool = False,
943930
min_count: int = 0,
944-
*args,
945-
**kwargs,
946931
):
947-
nv.validate_resampler_func("first", args, kwargs)
948932
return self._downsample("first", numeric_only=numeric_only, min_count=min_count)
949933

950934
@doc(GroupBy.last)
951935
def last(
952936
self,
953937
numeric_only: bool = False,
954938
min_count: int = 0,
955-
*args,
956-
**kwargs,
957939
):
958-
nv.validate_resampler_func("last", args, kwargs)
959940
return self._downsample("last", numeric_only=numeric_only, min_count=min_count)
960941

961942
@doc(GroupBy.median)
962-
def median(self, numeric_only: bool = False, *args, **kwargs):
963-
nv.validate_resampler_func("median", args, kwargs)
943+
def median(self, numeric_only: bool = False):
964944
return self._downsample("median", numeric_only=numeric_only)
965945

966946
def mean(
967947
self,
968948
numeric_only: bool = False,
969-
*args,
970-
**kwargs,
971949
):
972950
"""
973951
Compute mean of groups, excluding missing values.
@@ -986,15 +964,12 @@ def mean(
986964
DataFrame or Series
987965
Mean of values within each group.
988966
"""
989-
nv.validate_resampler_func("mean", args, kwargs)
990967
return self._downsample("mean", numeric_only=numeric_only)
991968

992969
def std(
993970
self,
994971
ddof: int = 1,
995972
numeric_only: bool = False,
996-
*args,
997-
**kwargs,
998973
):
999974
"""
1000975
Compute standard deviation of groups, excluding missing values.
@@ -1017,15 +992,12 @@ def std(
1017992
DataFrame or Series
1018993
Standard deviation of values within each group.
1019994
"""
1020-
nv.validate_resampler_func("std", args, kwargs)
1021995
return self._downsample("std", ddof=ddof, numeric_only=numeric_only)
1022996

1023997
def var(
1024998
self,
1025999
ddof: int = 1,
10261000
numeric_only: bool = False,
1027-
*args,
1028-
**kwargs,
10291001
):
10301002
"""
10311003
Compute variance of groups, excluding missing values.
@@ -1049,36 +1021,26 @@ def var(
10491021
DataFrame or Series
10501022
Variance of values within each group.
10511023
"""
1052-
nv.validate_resampler_func("var", args, kwargs)
10531024
return self._downsample("var", ddof=ddof, numeric_only=numeric_only)
10541025

10551026
@doc(GroupBy.sem)
10561027
def sem(
10571028
self,
10581029
ddof: int = 1,
10591030
numeric_only: bool = False,
1060-
*args,
1061-
**kwargs,
10621031
):
1063-
nv.validate_resampler_func("sem", args, kwargs)
10641032
return self._downsample("sem", ddof=ddof, numeric_only=numeric_only)
10651033

10661034
@doc(GroupBy.ohlc)
10671035
def ohlc(
10681036
self,
1069-
*args,
1070-
**kwargs,
10711037
):
1072-
nv.validate_resampler_func("ohlc", args, kwargs)
10731038
return self._downsample("ohlc")
10741039

10751040
@doc(SeriesGroupBy.nunique)
10761041
def nunique(
10771042
self,
1078-
*args,
1079-
**kwargs,
10801043
):
1081-
nv.validate_resampler_func("nunique", args, kwargs)
10821044
return self._downsample("nunique")
10831045

10841046
@doc(GroupBy.size)

pandas/tests/resample/test_datetime_index.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from pandas._libs import lib
1111
from pandas._typing import DatetimeNaTType
12-
from pandas.errors import UnsupportedFunctionCall
1312

1413
import pandas as pd
1514
from pandas import (
@@ -243,22 +242,6 @@ def _ohlc(group):
243242
tm.assert_frame_equal(result, expected)
244243

245244

246-
@pytest.mark.parametrize("func", ["min", "max", "sum", "prod", "mean", "var", "std"])
247-
def test_numpy_compat(func, unit):
248-
# see gh-12811
249-
s = Series(
250-
[1, 2, 3, 4, 5], index=date_range("20130101", periods=5, freq="s").as_unit(unit)
251-
)
252-
r = s.resample("2s")
253-
254-
msg = "numpy operations are not valid with resample"
255-
256-
with pytest.raises(UnsupportedFunctionCall, match=msg):
257-
getattr(r, func)(func, 1, 2, 3)
258-
with pytest.raises(UnsupportedFunctionCall, match=msg):
259-
getattr(r, func)(axis=1)
260-
261-
262245
def test_resample_how_callables(unit):
263246
# GH#7929
264247
data = np.arange(5, dtype=np.int64)

0 commit comments

Comments
 (0)