@@ -1071,6 +1071,10 @@ def any(self, skipna=True):
1071
1071
----------
1072
1072
skipna : bool, default True
1073
1073
Flag to ignore nan values during truth testing
1074
+
1075
+ Returns
1076
+ -------
1077
+ boolean
1074
1078
"""
1075
1079
return self ._bool_agg ('any' , skipna )
1076
1080
@@ -1084,6 +1088,10 @@ def all(self, skipna=True):
1084
1088
----------
1085
1089
skipna : bool, default True
1086
1090
Flag to ignore nan values during truth testing
1091
+
1092
+ Returns
1093
+ -------
1094
+ boolean
1087
1095
"""
1088
1096
return self ._bool_agg ('all' , skipna )
1089
1097
@@ -1092,6 +1100,11 @@ def all(self, skipna=True):
1092
1100
def count (self ):
1093
1101
"""
1094
1102
Compute count of group, excluding missing values.
1103
+
1104
+ Returns
1105
+ -------
1106
+ Series or DataFrame
1107
+ Count of values within each group.
1095
1108
"""
1096
1109
1097
1110
# defined here for API doc
@@ -1161,6 +1174,11 @@ def median(self, **kwargs):
1161
1174
Compute median of groups, excluding missing values.
1162
1175
1163
1176
For multiple groupings, the result index will be a MultiIndex
1177
+
1178
+ Returns
1179
+ -------
1180
+ Series or DataFrame
1181
+ Median of values within each group.
1164
1182
"""
1165
1183
try :
1166
1184
return self ._cython_agg_general ('median' , ** kwargs )
@@ -1187,6 +1205,11 @@ def std(self, ddof=1, *args, **kwargs):
1187
1205
----------
1188
1206
ddof : integer, default 1
1189
1207
degrees of freedom
1208
+
1209
+ Returns
1210
+ -------
1211
+ Series or DataFrame
1212
+ Standard deviation of values within each group.
1190
1213
"""
1191
1214
1192
1215
# TODO: implement at Cython level?
@@ -1205,6 +1228,11 @@ def var(self, ddof=1, *args, **kwargs):
1205
1228
----------
1206
1229
ddof : integer, default 1
1207
1230
degrees of freedom
1231
+
1232
+ Returns
1233
+ -------
1234
+ Series or DataFrame
1235
+ Variance of values within each group.
1208
1236
"""
1209
1237
nv .validate_groupby_func ('var' , args , kwargs )
1210
1238
if ddof == 1 :
@@ -1231,6 +1259,11 @@ def sem(self, ddof=1):
1231
1259
----------
1232
1260
ddof : integer, default 1
1233
1261
degrees of freedom
1262
+
1263
+ Returns
1264
+ -------
1265
+ Series or DataFrame
1266
+ Standard error of the mean of values within each group.
1234
1267
"""
1235
1268
1236
1269
return self .std (ddof = ddof ) / np .sqrt (self .count ())
@@ -1240,6 +1273,11 @@ def sem(self, ddof=1):
1240
1273
def size (self ):
1241
1274
"""
1242
1275
Compute group sizes.
1276
+
1277
+ Returns
1278
+ -------
1279
+ Series
1280
+ Number of rows in each group.
1243
1281
"""
1244
1282
result = self .grouper .size ()
1245
1283
@@ -1257,7 +1295,14 @@ def groupby_function(name, alias, npfunc,
1257
1295
numeric_only = True , _convert = False ,
1258
1296
min_count = - 1 ):
1259
1297
1260
- _local_template = "Compute %(f)s of group values"
1298
+ _local_template = """
1299
+ Compute %(f)s of group values
1300
+
1301
+ Returns
1302
+ -------
1303
+ Series or DataFrame
1304
+ %(f)s of values within each group.
1305
+ """
1261
1306
1262
1307
@Substitution (name = 'groupby' , f = name )
1263
1308
@Appender (_common_see_also )
@@ -1330,6 +1375,11 @@ def ohlc(self):
1330
1375
Compute sum of values, excluding missing values.
1331
1376
1332
1377
For multiple groupings, the result index will be a MultiIndex
1378
+
1379
+ Returns
1380
+ -------
1381
+ DataFrame
1382
+ Open, high, low and close values within each group.
1333
1383
"""
1334
1384
1335
1385
return self ._apply_to_column_groupbys (
@@ -1514,6 +1564,11 @@ def pad(self, limit=None):
1514
1564
limit : integer, optional
1515
1565
limit of how many values to fill
1516
1566
1567
+ Returns
1568
+ -------
1569
+ Series or DataFrame
1570
+ Object with missing values filled.
1571
+
1517
1572
See Also
1518
1573
--------
1519
1574
Series.pad
@@ -1534,6 +1589,11 @@ def backfill(self, limit=None):
1534
1589
limit : integer, optional
1535
1590
limit of how many values to fill
1536
1591
1592
+ Returns
1593
+ -------
1594
+ Series or DataFrame
1595
+ Object with missing values filled.
1596
+
1537
1597
See Also
1538
1598
--------
1539
1599
Series.backfill
@@ -1563,6 +1623,11 @@ def nth(self, n, dropna=None):
1563
1623
dropna : None or str, optional
1564
1624
apply the specified dropna operation before counting which row is
1565
1625
the nth row. Needs to be None, 'any' or 'all'
1626
+
1627
+ Returns
1628
+ -------
1629
+ Series or DataFrame
1630
+ Nth value within each group.
1566
1631
%(see_also)s
1567
1632
Examples
1568
1633
--------
@@ -1793,6 +1858,11 @@ def ngroup(self, ascending=True):
1793
1858
ascending : bool, default True
1794
1859
If False, number in reverse, from number of group - 1 to 0.
1795
1860
1861
+ Returns
1862
+ -------
1863
+ Series
1864
+ Unique numbers for each group.
1865
+
1796
1866
See Also
1797
1867
--------
1798
1868
.cumcount : Number the rows in each group.
@@ -1856,6 +1926,11 @@ def cumcount(self, ascending=True):
1856
1926
ascending : bool, default True
1857
1927
If False, number in reverse, from length of group - 1 to 0.
1858
1928
1929
+ Returns
1930
+ -------
1931
+ Series
1932
+ Sequence number of each element within each group.
1933
+
1859
1934
See Also
1860
1935
--------
1861
1936
.ngroup : Number the groups themselves.
@@ -1938,6 +2013,10 @@ def rank(self, method='average', ascending=True, na_option='keep',
1938
2013
def cumprod (self , axis = 0 , * args , ** kwargs ):
1939
2014
"""
1940
2015
Cumulative product for each group.
2016
+
2017
+ Returns
2018
+ -------
2019
+ Series or DataFrame
1941
2020
"""
1942
2021
nv .validate_groupby_func ('cumprod' , args , kwargs ,
1943
2022
['numeric_only' , 'skipna' ])
@@ -1951,6 +2030,10 @@ def cumprod(self, axis=0, *args, **kwargs):
1951
2030
def cumsum (self , axis = 0 , * args , ** kwargs ):
1952
2031
"""
1953
2032
Cumulative sum for each group.
2033
+
2034
+ Returns
2035
+ -------
2036
+ Series or DataFrame
1954
2037
"""
1955
2038
nv .validate_groupby_func ('cumsum' , args , kwargs ,
1956
2039
['numeric_only' , 'skipna' ])
@@ -1964,6 +2047,10 @@ def cumsum(self, axis=0, *args, **kwargs):
1964
2047
def cummin (self , axis = 0 , ** kwargs ):
1965
2048
"""
1966
2049
Cumulative min for each group.
2050
+
2051
+ Returns
2052
+ -------
2053
+ Series or DataFrame
1967
2054
"""
1968
2055
if axis != 0 :
1969
2056
return self .apply (lambda x : np .minimum .accumulate (x , axis ))
@@ -1975,6 +2062,10 @@ def cummin(self, axis=0, **kwargs):
1975
2062
def cummax (self , axis = 0 , ** kwargs ):
1976
2063
"""
1977
2064
Cumulative max for each group.
2065
+
2066
+ Returns
2067
+ -------
2068
+ Series or DataFrame
1978
2069
"""
1979
2070
if axis != 0 :
1980
2071
return self .apply (lambda x : np .maximum .accumulate (x , axis ))
@@ -2102,6 +2193,11 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None):
2102
2193
fill_value : optional
2103
2194
2104
2195
.. versionadded:: 0.24.0
2196
+
2197
+ Returns
2198
+ -------
2199
+ Series or DataFrame
2200
+ Object shifted within each group.
2105
2201
"""
2106
2202
2107
2203
if freq is not None or axis != 0 or not isna (fill_value ):
@@ -2120,6 +2216,11 @@ def pct_change(self, periods=1, fill_method='pad', limit=None, freq=None,
2120
2216
axis = 0 ):
2121
2217
"""
2122
2218
Calculate pct_change of each value to previous entry in group.
2219
+
2220
+ Returns
2221
+ -------
2222
+ Series or DataFrame
2223
+ Percentage changes within each group.
2123
2224
"""
2124
2225
if freq is not None or axis != 0 :
2125
2226
return self .apply (lambda x : x .pct_change (periods = periods ,
@@ -2140,6 +2241,10 @@ def head(self, n=5):
2140
2241
2141
2242
Essentially equivalent to ``.apply(lambda x: x.head(n))``,
2142
2243
except ignores as_index flag.
2244
+
2245
+ Returns
2246
+ -------
2247
+ Series or DataFrame
2143
2248
%(see_also)s
2144
2249
Examples
2145
2250
--------
@@ -2167,6 +2272,10 @@ def tail(self, n=5):
2167
2272
2168
2273
Essentially equivalent to ``.apply(lambda x: x.tail(n))``,
2169
2274
except ignores as_index flag.
2275
+
2276
+ Returns
2277
+ -------
2278
+ Series or DataFrame
2170
2279
%(see_also)s
2171
2280
Examples
2172
2281
--------
0 commit comments