bigframes.pandas.api.typing.SeriesGroupBy.mean#

SeriesGroupBy.mean(*args) Series[source]#

Compute mean of groups, excluding missing values.

Examples:

>>> df = bpd.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()
    B         C
A
1  3.0  1.333333
2  4.0       1.5

[2 rows x 2 columns]

Groupby two columns and return the mean of the remaining column.

>>> df.groupby(['A', 'B']).mean()
         C
A B
1 2.0  2.0
  4.0  1.0
2 3.0  1.0
  5.0  2.0

[4 rows x 1 columns]

Groupby one column and return the mean of only particular column in the group.

>>> df.groupby('A')['B'].mean()
A
1    3.0
2    4.0
Name: B, dtype: Float64
Parameters:

numeric_only (bool, default False) – Include only float, int, boolean columns.

Returns:

Mean of groups.

Return type:

bigframes.pandas.DataFrame or bigframes.pandas.Series