snowflake.snowpark.modin.plugin.extensions.groupby_overrides.DataFrameGroupBy.size¶
- DataFrameGroupBy.size()[source]¶
Compute group sizes.
- 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:
DataFrame
or Series
Examples
>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]] >>> df = pd.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 >>> df.groupby("a").size() a 1 2 7 1 dtype: int64
For SeriesGroupBy:
>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]] >>> df = pd.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 >>> df.groupby("a")["b"].size() a 1 2 7 1 Name: b, dtype: int64