databricks.koalas.groupby.GroupBy.mean

GroupBy.mean() → Union[databricks.koalas.frame.DataFrame, databricks.koalas.series.Series][source]

Compute mean of groups, excluding missing values.

Returns
koalas.Series or koalas.DataFrame

Examples

>>> df = ks.DataFrame({'A': [1, 1, 2, 1, 2],
...                    'B': [np.nan, 2, 3, 4, 5],
...                    'C': [1, 2, 1, 1, 2]}, columns=['A', 'B', 'C'])

Groupby one column and return the mean of the remaining columns in each group.

>>> df.groupby('A').mean().sort_index()  
     B         C
A
1  3.0  1.333333
2  4.0  1.500000