bigframes.pandas.api.typing.DataFrameGroupBy.median#

DataFrameGroupBy.median(numeric_only: bool = False, *, exact: bool = True) DataFrame[source]#

Compute median of groups, excluding missing values.

Examples:

For SeriesGroupBy:

>>> import bigframes.pandas as bpd
>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = bpd.Series([7, 2, 8, 4, 3, 3], index=lst)
>>> ser.groupby(level=0).median()
a    7.0
b    3.0
dtype: Float64

For DataFrameGroupBy:

>>> data = {'a': [1, 3, 5, 7, 7, 8, 3], 'b': [1, 4, 8, 4, 4, 2, 1]}
>>> df = bpd.DataFrame(data, index=['dog', 'dog', 'dog',
...                    'mouse', 'mouse', 'mouse', 'mouse'])
>>> df.groupby(level=0).median()
        a    b
dog    3.0  4.0
mouse  7.0  3.0

[2 rows x 2 columns]
Parameters:
  • numeric_only (bool, default False) – Include only float, int, boolean columns.

  • exact (bool, default True) – Calculate the exact median instead of an approximation.

Returns:

Median of groups.

Return type:

bigframes.pandas.DataFrame or bigframes.pandas.Series