bigframes.pandas.api.typing.DataFrameGroupBy.cumcount#
- DataFrameGroupBy.cumcount(ascending: bool = True) Series[source]#
Number each item in each group from 0 to the length of that group - 1.
Examples:
For SeriesGroupBy:
>>> lst = ['a', 'a', 'b', 'b', 'c'] >>> ser = bpd.Series([5, 1, 2, 3, 4], index=lst) >>> ser.groupby(level=0).cumcount() a 0 a 1 b 0 b 1 c 0 dtype: Int64 >>> ser.groupby(level=0).cumcount(ascending=False) a 0 a 1 b 0 b 1 c 0 dtype: Int64
- Parameters:
ascending (bool, default True) – If False, number in reverse, from length of group - 1 to 0.
- Returns:
Sequence number of each element within each group.
- Return type: