@@ -1297,9 +1297,48 @@ def count(self):
12971297 @Appender (_doc_template )
12981298 def mean (self , * args , ** kwargs ):
12991299 """
1300- Compute mean of groups, excluding missing values
1300+ Compute mean of groups, excluding missing values.
13011301
1302- For multiple groupings, the result index will be a MultiIndex
1302+ Returns
1303+ -------
1304+ pandas.Series or pandas.DataFrame
1305+
1306+ Examples
1307+ --------
1308+ >>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2],
1309+ ... 'B': [np.nan, 2, 3, 4, 5],
1310+ ... 'C': [1, 2, 1, 1, 2]}, columns=['A', 'B', 'C'])
1311+
1312+ Groupby one column and return the mean of the remaining columns in
1313+ each group.
1314+
1315+ >>> df.groupby('A').mean()
1316+ >>>
1317+ B C
1318+ A
1319+ 1 3.0 1.333333
1320+ 2 4.0 1.500000
1321+
1322+ Groupby two columns and return the mean of the remaining column.
1323+
1324+ >>> df.groupby(['A', 'B']).mean()
1325+ >>>
1326+ C
1327+ A B
1328+ 1 2.0 2
1329+ 4.0 1
1330+ 2 3.0 1
1331+ 5.0 2
1332+
1333+ Groupby one column and return the mean of only particular column in
1334+ the group.
1335+
1336+ >>> df.groupby('A')['B'].mean()
1337+ >>>
1338+ A
1339+ 1 3.0
1340+ 2 4.0
1341+ Name: B, dtype: float64
13031342 """
13041343 nv .validate_groupby_func ('mean' , args , kwargs , ['numeric_only' ])
13051344 try :
0 commit comments