27
27
)
28
28
from pandas ._libs .tslibs .dtypes import freq_to_period_freqstr
29
29
from pandas ._typing import NDFrameT
30
- from pandas .compat .numpy import function as nv
31
30
from pandas .errors import AbstractMethodError
32
31
from pandas .util ._decorators import (
33
32
Appender ,
@@ -1156,8 +1155,6 @@ def sum(
1156
1155
self ,
1157
1156
numeric_only : bool = False ,
1158
1157
min_count : int = 0 ,
1159
- * args ,
1160
- ** kwargs ,
1161
1158
):
1162
1159
"""
1163
1160
Compute sum of group values.
@@ -1195,17 +1192,13 @@ def sum(
1195
1192
2023-02-01 7
1196
1193
Freq: MS, dtype: int64
1197
1194
"""
1198
- maybe_warn_args_and_kwargs (type (self ), "sum" , args , kwargs )
1199
- nv .validate_resampler_func ("sum" , args , kwargs )
1200
1195
return self ._downsample ("sum" , numeric_only = numeric_only , min_count = min_count )
1201
1196
1202
1197
@final
1203
1198
def prod (
1204
1199
self ,
1205
1200
numeric_only : bool = False ,
1206
1201
min_count : int = 0 ,
1207
- * args ,
1208
- ** kwargs ,
1209
1202
):
1210
1203
"""
1211
1204
Compute prod of group values.
@@ -1243,17 +1236,13 @@ def prod(
1243
1236
2023-02-01 12
1244
1237
Freq: MS, dtype: int64
1245
1238
"""
1246
- maybe_warn_args_and_kwargs (type (self ), "prod" , args , kwargs )
1247
- nv .validate_resampler_func ("prod" , args , kwargs )
1248
1239
return self ._downsample ("prod" , numeric_only = numeric_only , min_count = min_count )
1249
1240
1250
1241
@final
1251
1242
def min (
1252
1243
self ,
1253
1244
numeric_only : bool = False ,
1254
1245
min_count : int = 0 ,
1255
- * args ,
1256
- ** kwargs ,
1257
1246
):
1258
1247
"""
1259
1248
Compute min value of group.
@@ -1277,18 +1266,13 @@ def min(
1277
1266
2023-02-01 3
1278
1267
Freq: MS, dtype: int64
1279
1268
"""
1280
-
1281
- maybe_warn_args_and_kwargs (type (self ), "min" , args , kwargs )
1282
- nv .validate_resampler_func ("min" , args , kwargs )
1283
1269
return self ._downsample ("min" , numeric_only = numeric_only , min_count = min_count )
1284
1270
1285
1271
@final
1286
1272
def max (
1287
1273
self ,
1288
1274
numeric_only : bool = False ,
1289
1275
min_count : int = 0 ,
1290
- * args ,
1291
- ** kwargs ,
1292
1276
):
1293
1277
"""
1294
1278
Compute max value of group.
@@ -1312,8 +1296,6 @@ def max(
1312
1296
2023-02-01 4
1313
1297
Freq: MS, dtype: int64
1314
1298
"""
1315
- maybe_warn_args_and_kwargs (type (self ), "max" , args , kwargs )
1316
- nv .validate_resampler_func ("max" , args , kwargs )
1317
1299
return self ._downsample ("max" , numeric_only = numeric_only , min_count = min_count )
1318
1300
1319
1301
@final
@@ -1323,11 +1305,7 @@ def first(
1323
1305
numeric_only : bool = False ,
1324
1306
min_count : int = 0 ,
1325
1307
skipna : bool = True ,
1326
- * args ,
1327
- ** kwargs ,
1328
1308
):
1329
- maybe_warn_args_and_kwargs (type (self ), "first" , args , kwargs )
1330
- nv .validate_resampler_func ("first" , args , kwargs )
1331
1309
return self ._downsample (
1332
1310
"first" , numeric_only = numeric_only , min_count = min_count , skipna = skipna
1333
1311
)
@@ -1339,28 +1317,20 @@ def last(
1339
1317
numeric_only : bool = False ,
1340
1318
min_count : int = 0 ,
1341
1319
skipna : bool = True ,
1342
- * args ,
1343
- ** kwargs ,
1344
1320
):
1345
- maybe_warn_args_and_kwargs (type (self ), "last" , args , kwargs )
1346
- nv .validate_resampler_func ("last" , args , kwargs )
1347
1321
return self ._downsample (
1348
1322
"last" , numeric_only = numeric_only , min_count = min_count , skipna = skipna
1349
1323
)
1350
1324
1351
1325
@final
1352
1326
@doc (GroupBy .median )
1353
- def median (self , numeric_only : bool = False , * args , ** kwargs ):
1354
- maybe_warn_args_and_kwargs (type (self ), "median" , args , kwargs )
1355
- nv .validate_resampler_func ("median" , args , kwargs )
1327
+ def median (self , numeric_only : bool = False ):
1356
1328
return self ._downsample ("median" , numeric_only = numeric_only )
1357
1329
1358
1330
@final
1359
1331
def mean (
1360
1332
self ,
1361
1333
numeric_only : bool = False ,
1362
- * args ,
1363
- ** kwargs ,
1364
1334
):
1365
1335
"""
1366
1336
Compute mean of groups, excluding missing values.
@@ -1395,17 +1365,13 @@ def mean(
1395
1365
2023-02-01 3.5
1396
1366
Freq: MS, dtype: float64
1397
1367
"""
1398
- maybe_warn_args_and_kwargs (type (self ), "mean" , args , kwargs )
1399
- nv .validate_resampler_func ("mean" , args , kwargs )
1400
1368
return self ._downsample ("mean" , numeric_only = numeric_only )
1401
1369
1402
1370
@final
1403
1371
def std (
1404
1372
self ,
1405
1373
ddof : int = 1 ,
1406
1374
numeric_only : bool = False ,
1407
- * args ,
1408
- ** kwargs ,
1409
1375
):
1410
1376
"""
1411
1377
Compute standard deviation of groups, excluding missing values.
@@ -1443,17 +1409,13 @@ def std(
1443
1409
2023-02-01 2.645751
1444
1410
Freq: MS, dtype: float64
1445
1411
"""
1446
- maybe_warn_args_and_kwargs (type (self ), "std" , args , kwargs )
1447
- nv .validate_resampler_func ("std" , args , kwargs )
1448
1412
return self ._downsample ("std" , ddof = ddof , numeric_only = numeric_only )
1449
1413
1450
1414
@final
1451
1415
def var (
1452
1416
self ,
1453
1417
ddof : int = 1 ,
1454
1418
numeric_only : bool = False ,
1455
- * args ,
1456
- ** kwargs ,
1457
1419
):
1458
1420
"""
1459
1421
Compute variance of groups, excluding missing values.
@@ -1497,8 +1459,6 @@ def var(
1497
1459
2023-02-01 4.666667
1498
1460
Freq: MS, dtype: float64
1499
1461
"""
1500
- maybe_warn_args_and_kwargs (type (self ), "var" , args , kwargs )
1501
- nv .validate_resampler_func ("var" , args , kwargs )
1502
1462
return self ._downsample ("var" , ddof = ddof , numeric_only = numeric_only )
1503
1463
1504
1464
@final
@@ -1507,23 +1467,12 @@ def sem(
1507
1467
self ,
1508
1468
ddof : int = 1 ,
1509
1469
numeric_only : bool = False ,
1510
- * args ,
1511
- ** kwargs ,
1512
1470
):
1513
- maybe_warn_args_and_kwargs (type (self ), "sem" , args , kwargs )
1514
- nv .validate_resampler_func ("sem" , args , kwargs )
1515
1471
return self ._downsample ("sem" , ddof = ddof , numeric_only = numeric_only )
1516
1472
1517
1473
@final
1518
1474
@doc (GroupBy .ohlc )
1519
- def ohlc (
1520
- self ,
1521
- * args ,
1522
- ** kwargs ,
1523
- ):
1524
- maybe_warn_args_and_kwargs (type (self ), "ohlc" , args , kwargs )
1525
- nv .validate_resampler_func ("ohlc" , args , kwargs )
1526
-
1475
+ def ohlc (self ):
1527
1476
ax = self .ax
1528
1477
obj = self ._obj_with_exclusions
1529
1478
if len (ax ) == 0 :
@@ -1544,13 +1493,7 @@ def ohlc(
1544
1493
1545
1494
@final
1546
1495
@doc (SeriesGroupBy .nunique )
1547
- def nunique (
1548
- self ,
1549
- * args ,
1550
- ** kwargs ,
1551
- ):
1552
- maybe_warn_args_and_kwargs (type (self ), "nunique" , args , kwargs )
1553
- nv .validate_resampler_func ("nunique" , args , kwargs )
1496
+ def nunique (self ):
1554
1497
return self ._downsample ("nunique" )
1555
1498
1556
1499
@final
@@ -2874,40 +2817,6 @@ def _asfreq_compat(index: DatetimeIndex | PeriodIndex | TimedeltaIndex, freq):
2874
2817
return new_index
2875
2818
2876
2819
2877
- def maybe_warn_args_and_kwargs (cls , kernel : str , args , kwargs ) -> None :
2878
- """
2879
- Warn for deprecation of args and kwargs in resample functions.
2880
-
2881
- Parameters
2882
- ----------
2883
- cls : type
2884
- Class to warn about.
2885
- kernel : str
2886
- Operation name.
2887
- args : tuple or None
2888
- args passed by user. Will be None if and only if kernel does not have args.
2889
- kwargs : dict or None
2890
- kwargs passed by user. Will be None if and only if kernel does not have kwargs.
2891
- """
2892
- warn_args = args is not None and len (args ) > 0
2893
- warn_kwargs = kwargs is not None and len (kwargs ) > 0
2894
- if warn_args and warn_kwargs :
2895
- msg = "args and kwargs"
2896
- elif warn_args :
2897
- msg = "args"
2898
- elif warn_kwargs :
2899
- msg = "kwargs"
2900
- else :
2901
- return
2902
- warnings .warn (
2903
- f"Passing additional { msg } to { cls .__name__ } .{ kernel } has "
2904
- "no impact on the result and is deprecated. This will "
2905
- "raise a TypeError in a future version of pandas." ,
2906
- category = FutureWarning ,
2907
- stacklevel = find_stack_level (),
2908
- )
2909
-
2910
-
2911
2820
def _apply (
2912
2821
grouped : GroupBy , how : Callable , * args , include_groups : bool , ** kwargs
2913
2822
) -> DataFrame :
0 commit comments