bigframes.pandas.api.typing.DataFrameGroupBy.var#

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

Compute variance of groups, excluding missing values.

For multiple groupings, the result index will be a MultiIndex.

Examples:

For SeriesGroupBy:

>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = bpd.Series([7, 2, 8, 4, 3, 3], index=lst)
>>> ser.groupby(level=0).var()
a   10.333333
b    0.333333
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).var()
              a          b
dog         4.0  12.333333
mouse  4.916667       2.25

[2 rows x 2 columns]
Parameters:

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

Returns:

Variance of values within each group.

Return type:

bigframes.pandas.DataFrame or bigframes.pandas.Series