@@ -41,7 +41,7 @@ class providing the base-class of operations.
41
41
from pandas .core .series import Series
42
42
from pandas .core .sorting import get_group_index_sorter
43
43
44
- _doc_template = """
44
+ _common_see_also = """
45
45
See Also
46
46
--------
47
47
pandas.Series.%(name)s
@@ -1044,7 +1044,7 @@ def result_to_bool(result):
1044
1044
val_test = val_test , skipna = skipna )
1045
1045
1046
1046
@Substitution (name = 'groupby' )
1047
- @Appender (_doc_template )
1047
+ @Appender (_common_see_also )
1048
1048
def any (self , skipna = True ):
1049
1049
"""
1050
1050
Returns True if any value in the group is truthful, else False.
@@ -1057,7 +1057,7 @@ def any(self, skipna=True):
1057
1057
return self ._bool_agg ('any' , skipna )
1058
1058
1059
1059
@Substitution (name = 'groupby' )
1060
- @Appender (_doc_template )
1060
+ @Appender (_common_see_also )
1061
1061
def all (self , skipna = True ):
1062
1062
"""
1063
1063
Returns True if all values in the group are truthful, else False.
@@ -1070,7 +1070,7 @@ def all(self, skipna=True):
1070
1070
return self ._bool_agg ('all' , skipna )
1071
1071
1072
1072
@Substitution (name = 'groupby' )
1073
- @Appender (_doc_template )
1073
+ @Appender (_common_see_also )
1074
1074
def count (self ):
1075
1075
"""
1076
1076
Compute count of group, excluding missing values.
@@ -1079,7 +1079,8 @@ def count(self):
1079
1079
# defined here for API doc
1080
1080
raise NotImplementedError
1081
1081
1082
- @Substitution (name = 'groupby' )
1082
+ @Substitution (name = 'groupby' ,
1083
+ see_also = _common_see_also )
1083
1084
def mean (self , * args , ** kwargs ):
1084
1085
"""
1085
1086
Compute mean of groups, excluding missing values.
@@ -1088,11 +1089,7 @@ def mean(self, *args, **kwargs):
1088
1089
-------
1089
1090
pandas.Series or pandas.DataFrame
1090
1091
1091
- See Also
1092
- --------
1093
- pandas.Series.%(name)s
1094
- pandas.DataFrame.%(name)s
1095
- pandas.Panel.%(name)s
1092
+ %(see_also)s
1096
1093
1097
1094
Examples
1098
1095
--------
@@ -1142,7 +1139,7 @@ def mean(self, *args, **kwargs):
1142
1139
return self ._python_agg_general (f )
1143
1140
1144
1141
@Substitution (name = 'groupby' )
1145
- @Appender (_doc_template )
1142
+ @Appender (_common_see_also )
1146
1143
def median (self , ** kwargs ):
1147
1144
"""
1148
1145
Compute median of groups, excluding missing values.
@@ -1163,7 +1160,7 @@ def f(x):
1163
1160
return self ._python_agg_general (f )
1164
1161
1165
1162
@Substitution (name = 'groupby' )
1166
- @Appender (_doc_template )
1163
+ @Appender (_common_see_also )
1167
1164
def std (self , ddof = 1 , * args , ** kwargs ):
1168
1165
"""
1169
1166
Compute standard deviation of groups, excluding missing values.
@@ -1181,7 +1178,7 @@ def std(self, ddof=1, *args, **kwargs):
1181
1178
return np .sqrt (self .var (ddof = ddof , ** kwargs ))
1182
1179
1183
1180
@Substitution (name = 'groupby' )
1184
- @Appender (_doc_template )
1181
+ @Appender (_common_see_also )
1185
1182
def var (self , ddof = 1 , * args , ** kwargs ):
1186
1183
"""
1187
1184
Compute variance of groups, excluding missing values.
@@ -1207,7 +1204,7 @@ def var(self, ddof=1, *args, **kwargs):
1207
1204
return self ._python_agg_general (f )
1208
1205
1209
1206
@Substitution (name = 'groupby' )
1210
- @Appender (_doc_template )
1207
+ @Appender (_common_see_also )
1211
1208
def sem (self , ddof = 1 ):
1212
1209
"""
1213
1210
Compute standard error of the mean of groups, excluding missing values.
@@ -1223,7 +1220,7 @@ def sem(self, ddof=1):
1223
1220
return self .std (ddof = ddof ) / np .sqrt (self .count ())
1224
1221
1225
1222
@Substitution (name = 'groupby' )
1226
- @Appender (_doc_template )
1223
+ @Appender (_common_see_also )
1227
1224
def size (self ):
1228
1225
"""
1229
1226
Compute group sizes.
@@ -1247,7 +1244,7 @@ def groupby_function(name, alias, npfunc,
1247
1244
_local_template = "Compute %(f)s of group values"
1248
1245
1249
1246
@Substitution (name = 'groupby' , f = name )
1250
- @Appender (_doc_template )
1247
+ @Appender (_common_see_also )
1251
1248
@Appender (_local_template )
1252
1249
def f (self , ** kwargs ):
1253
1250
if 'numeric_only' not in kwargs :
@@ -1312,7 +1309,7 @@ def last(x):
1312
1309
numeric_only = False )
1313
1310
1314
1311
@Substitution (name = 'groupby' )
1315
- @Appender (_doc_template )
1312
+ @Appender (_common_see_also )
1316
1313
def ohlc (self ):
1317
1314
"""
1318
1315
Compute sum of values, excluding missing values.
@@ -1441,7 +1438,7 @@ def resample(self, rule, *args, **kwargs):
1441
1438
return get_resampler_for_grouping (self , rule , * args , ** kwargs )
1442
1439
1443
1440
@Substitution (name = 'groupby' )
1444
- @Appender (_doc_template )
1441
+ @Appender (_common_see_also )
1445
1442
def rolling (self , * args , ** kwargs ):
1446
1443
"""
1447
1444
Return a rolling grouper, providing rolling functionality per group.
@@ -1450,7 +1447,7 @@ def rolling(self, *args, **kwargs):
1450
1447
return RollingGroupby (self , * args , ** kwargs )
1451
1448
1452
1449
@Substitution (name = 'groupby' )
1453
- @Appender (_doc_template )
1450
+ @Appender (_common_see_also )
1454
1451
def expanding (self , * args , ** kwargs ):
1455
1452
"""
1456
1453
Return an expanding grouper, providing expanding
@@ -1532,7 +1529,8 @@ def backfill(self, limit=None):
1532
1529
return self ._fill ('bfill' , limit = limit )
1533
1530
bfill = backfill
1534
1531
1535
- @Substitution (name = 'groupby' )
1532
+ @Substitution (name = 'groupby' ,
1533
+ see_also = _common_see_also )
1536
1534
def nth (self , n , dropna = None ):
1537
1535
"""
1538
1536
Take the nth row from each group if n is an int, or a subset of rows
@@ -1551,11 +1549,7 @@ def nth(self, n, dropna=None):
1551
1549
apply the specified dropna operation before counting which row is
1552
1550
the nth row. Needs to be None, 'any' or 'all'
1553
1551
1554
- See Also
1555
- --------
1556
- pandas.Series.%(name)s
1557
- pandas.DataFrame.%(name)s
1558
- pandas.Panel.%(name)s
1552
+ %(see_also)s
1559
1553
1560
1554
Examples
1561
1555
--------
@@ -1818,7 +1812,7 @@ def cumcount(self, ascending=True):
1818
1812
return Series (cumcounts , index )
1819
1813
1820
1814
@Substitution (name = 'groupby' )
1821
- @Appender (_doc_template )
1815
+ @Appender (_common_see_also )
1822
1816
def rank (self , method = 'average' , ascending = True , na_option = 'keep' ,
1823
1817
pct = False , axis = 0 ):
1824
1818
"""
@@ -1855,7 +1849,7 @@ def rank(self, method='average', ascending=True, na_option='keep',
1855
1849
na_option = na_option , pct = pct , axis = axis )
1856
1850
1857
1851
@Substitution (name = 'groupby' )
1858
- @Appender (_doc_template )
1852
+ @Appender (_common_see_also )
1859
1853
def cumprod (self , axis = 0 , * args , ** kwargs ):
1860
1854
"""
1861
1855
Cumulative product for each group.
@@ -1868,7 +1862,7 @@ def cumprod(self, axis=0, *args, **kwargs):
1868
1862
return self ._cython_transform ('cumprod' , ** kwargs )
1869
1863
1870
1864
@Substitution (name = 'groupby' )
1871
- @Appender (_doc_template )
1865
+ @Appender (_common_see_also )
1872
1866
def cumsum (self , axis = 0 , * args , ** kwargs ):
1873
1867
"""
1874
1868
Cumulative sum for each group.
@@ -1881,7 +1875,7 @@ def cumsum(self, axis=0, *args, **kwargs):
1881
1875
return self ._cython_transform ('cumsum' , ** kwargs )
1882
1876
1883
1877
@Substitution (name = 'groupby' )
1884
- @Appender (_doc_template )
1878
+ @Appender (_common_see_also )
1885
1879
def cummin (self , axis = 0 , ** kwargs ):
1886
1880
"""
1887
1881
Cumulative min for each group.
@@ -1892,7 +1886,7 @@ def cummin(self, axis=0, **kwargs):
1892
1886
return self ._cython_transform ('cummin' , numeric_only = False )
1893
1887
1894
1888
@Substitution (name = 'groupby' )
1895
- @Appender (_doc_template )
1889
+ @Appender (_common_see_also )
1896
1890
def cummax (self , axis = 0 , ** kwargs ):
1897
1891
"""
1898
1892
Cumulative max for each group.
@@ -2001,7 +1995,7 @@ def _get_cythonized_result(self, how, grouper, aggregate=False,
2001
1995
return self ._wrap_transformed_output (output )
2002
1996
2003
1997
@Substitution (name = 'groupby' )
2004
- @Appender (_doc_template )
1998
+ @Appender (_common_see_also )
2005
1999
def shift (self , periods = 1 , freq = None , axis = 0 ):
2006
2000
"""
2007
2001
Shift each group by periods observations.
@@ -2024,7 +2018,7 @@ def shift(self, periods=1, freq=None, axis=0):
2024
2018
periods = periods )
2025
2019
2026
2020
@Substitution (name = 'groupby' )
2027
- @Appender (_doc_template )
2021
+ @Appender (_common_see_also )
2028
2022
def pct_change (self , periods = 1 , fill_method = 'pad' , limit = None , freq = None ,
2029
2023
axis = 0 ):
2030
2024
"""
@@ -2041,19 +2035,16 @@ def pct_change(self, periods=1, fill_method='pad', limit=None, freq=None,
2041
2035
shifted = fill_grp .shift (periods = periods , freq = freq )
2042
2036
return (filled / shifted ) - 1
2043
2037
2044
- @Substitution (name = 'groupby' )
2038
+ @Substitution (name = 'groupby' ,
2039
+ see_also = _common_see_also )
2045
2040
def head (self , n = 5 ):
2046
2041
"""
2047
2042
Returns first n rows of each group.
2048
2043
2049
2044
Essentially equivalent to ``.apply(lambda x: x.head(n))``,
2050
2045
except ignores as_index flag.
2051
2046
2052
- See Also
2053
- --------
2054
- pandas.Series.%(name)s
2055
- pandas.DataFrame.%(name)s
2056
- pandas.Panel.%(name)s
2047
+ %(see_also)s
2057
2048
2058
2049
Examples
2059
2050
--------
@@ -2073,19 +2064,16 @@ def head(self, n=5):
2073
2064
mask = self ._cumcount_array () < n
2074
2065
return self ._selected_obj [mask ]
2075
2066
2076
- @Substitution (name = 'groupby' )
2067
+ @Substitution (name = 'groupby' ,
2068
+ see_also = _common_see_also )
2077
2069
def tail (self , n = 5 ):
2078
2070
"""
2079
2071
Returns last n rows of each group.
2080
2072
2081
2073
Essentially equivalent to ``.apply(lambda x: x.tail(n))``,
2082
2074
except ignores as_index flag.
2083
2075
2084
- See Also
2085
- --------
2086
- pandas.Series.%(name)s
2087
- pandas.DataFrame.%(name)s
2088
- pandas.Panel.%(name)s
2076
+ %(see_also)s
2089
2077
2090
2078
Examples
2091
2079
--------
0 commit comments