bigframes.pandas.api.typing.DataFrameGroupBy.size#

DataFrameGroupBy.size() DataFrame | Series[source]#

Compute group sizes.

Examples:

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = bpd.Series([1, 2, 3], index=lst)
>>> ser
a     1
a     2
b     3
dtype: Int64
>>> ser.groupby(level=0).size()
a    2
b    1
dtype: Int64

For DataFrameGroupBy:

>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]]
>>> df = bpd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["owl", "toucan", "eagle"])
>>> df
        a  b  c
owl     1  2  3
toucan  1  5  6
eagle   7  8  9
[3 rows x 3 columns]
>>> df.groupby("a").size()
a
1    2
7    1
dtype: Int64
Returns:

Number of rows in each group as a Series if as_index is True or a DataFrame if as_index is False.

Return type:

bigframes.pandas.DataFrame or bigframes.pandas.Series