@@ -1109,18 +1109,89 @@ def sum(
1109
1109
* args ,
1110
1110
** kwargs ,
1111
1111
):
1112
+ """
1113
+ Compute sum of group values.
1114
+
1115
+ Parameters
1116
+ ----------
1117
+ numeric_only : bool, default False
1118
+ Include only float, int, boolean columns.
1119
+
1120
+ .. versionchanged:: 2.0.0
1121
+
1122
+ numeric_only no longer accepts ``None``.
1123
+
1124
+ min_count : int, default 0
1125
+ The required number of valid values to perform the operation. If fewer
1126
+ than ``min_count`` non-NA values are present the result will be NA.
1127
+
1128
+ Returns
1129
+ -------
1130
+ Series or DataFrame
1131
+ Computed sum of values within each group.
1132
+
1133
+ Examples
1134
+ --------
1135
+ >>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
1136
+ ... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
1137
+ >>> ser
1138
+ 2023-01-01 1
1139
+ 2023-01-15 2
1140
+ 2023-02-01 3
1141
+ 2023-02-15 4
1142
+ dtype: int64
1143
+ >>> ser.resample('MS').sum()
1144
+ 2023-01-01 3
1145
+ 2023-02-01 7
1146
+ Freq: MS, dtype: int64
1147
+ """
1112
1148
maybe_warn_args_and_kwargs (type (self ), "sum" , args , kwargs )
1113
1149
nv .validate_resampler_func ("sum" , args , kwargs )
1114
1150
return self ._downsample ("sum" , numeric_only = numeric_only , min_count = min_count )
1115
1151
1116
- @doc (GroupBy .prod )
1117
1152
def prod (
1118
1153
self ,
1119
1154
numeric_only : bool = False ,
1120
1155
min_count : int = 0 ,
1121
1156
* args ,
1122
1157
** kwargs ,
1123
1158
):
1159
+ """
1160
+ Compute prod of group values.
1161
+
1162
+ Parameters
1163
+ ----------
1164
+ numeric_only : bool, default False
1165
+ Include only float, int, boolean columns.
1166
+
1167
+ .. versionchanged:: 2.0.0
1168
+
1169
+ numeric_only no longer accepts ``None``.
1170
+
1171
+ min_count : int, default 0
1172
+ The required number of valid values to perform the operation. If fewer
1173
+ than ``min_count`` non-NA values are present the result will be NA.
1174
+
1175
+ Returns
1176
+ -------
1177
+ Series or DataFrame
1178
+ Computed prod of values within each group.
1179
+
1180
+ Examples
1181
+ --------
1182
+ >>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
1183
+ ... ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
1184
+ >>> ser
1185
+ 2023-01-01 1
1186
+ 2023-01-15 2
1187
+ 2023-02-01 3
1188
+ 2023-02-15 4
1189
+ dtype: int64
1190
+ >>> ser.resample('MS').prod()
1191
+ 2023-01-01 2
1192
+ 2023-02-01 12
1193
+ Freq: MS, dtype: int64
1194
+ """
1124
1195
maybe_warn_args_and_kwargs (type (self ), "prod" , args , kwargs )
1125
1196
nv .validate_resampler_func ("prod" , args , kwargs )
1126
1197
return self ._downsample ("prod" , numeric_only = numeric_only , min_count = min_count )
@@ -1292,6 +1363,21 @@ def std(
1292
1363
-------
1293
1364
DataFrame or Series
1294
1365
Standard deviation of values within each group.
1366
+
1367
+ Examples
1368
+ --------
1369
+
1370
+ >>> ser = pd.Series([1, 3, 2, 4, 3, 8],
1371
+ ... index=pd.DatetimeIndex(['2023-01-01',
1372
+ ... '2023-01-10',
1373
+ ... '2023-01-15',
1374
+ ... '2023-02-01',
1375
+ ... '2023-02-10',
1376
+ ... '2023-02-15']))
1377
+ >>> ser.resample('MS').std()
1378
+ 2023-01-01 1.000000
1379
+ 2023-02-01 2.645751
1380
+ Freq: MS, dtype: float64
1295
1381
"""
1296
1382
maybe_warn_args_and_kwargs (type (self ), "std" , args , kwargs )
1297
1383
nv .validate_resampler_func ("std" , args , kwargs )
@@ -1325,6 +1411,26 @@ def var(
1325
1411
-------
1326
1412
DataFrame or Series
1327
1413
Variance of values within each group.
1414
+
1415
+ Examples
1416
+ --------
1417
+
1418
+ >>> ser = pd.Series([1, 3, 2, 4, 3, 8],
1419
+ ... index=pd.DatetimeIndex(['2023-01-01',
1420
+ ... '2023-01-10',
1421
+ ... '2023-01-15',
1422
+ ... '2023-02-01',
1423
+ ... '2023-02-10',
1424
+ ... '2023-02-15']))
1425
+ >>> ser.resample('MS').var()
1426
+ 2023-01-01 1.0
1427
+ 2023-02-01 7.0
1428
+ Freq: MS, dtype: float64
1429
+
1430
+ >>> ser.resample('MS').var(ddof=0)
1431
+ 2023-01-01 0.666667
1432
+ 2023-02-01 4.666667
1433
+ Freq: MS, dtype: float64
1328
1434
"""
1329
1435
maybe_warn_args_and_kwargs (type (self ), "var" , args , kwargs )
1330
1436
nv .validate_resampler_func ("var" , args , kwargs )
@@ -1421,6 +1527,26 @@ def quantile(self, q: float | AnyArrayLike = 0.5, **kwargs):
1421
1527
DataFrameGroupBy.quantile
1422
1528
Return a DataFrame, where the columns are groupby columns,
1423
1529
and the values are its quantiles.
1530
+
1531
+ Examples
1532
+ --------
1533
+
1534
+ >>> ser = pd.Series([1, 3, 2, 4, 3, 8],
1535
+ ... index=pd.DatetimeIndex(['2023-01-01',
1536
+ ... '2023-01-10',
1537
+ ... '2023-01-15',
1538
+ ... '2023-02-01',
1539
+ ... '2023-02-10',
1540
+ ... '2023-02-15']))
1541
+ >>> ser.resample('MS').quantile()
1542
+ 2023-01-01 2.0
1543
+ 2023-02-01 4.0
1544
+ Freq: MS, dtype: float64
1545
+
1546
+ >>> ser.resample('MS').quantile(.25)
1547
+ 2023-01-01 1.5
1548
+ 2023-02-01 3.5
1549
+ Freq: MS, dtype: float64
1424
1550
"""
1425
1551
return self ._downsample ("quantile" , q = q , ** kwargs )
1426
1552
0 commit comments