pyspark.pandas.groupby.GroupBy.cummax

GroupBy.cummax() → FrameLike[source]

Cumulative max for each group.

Returns
Series or DataFrame

See also

Series.cummax
DataFrame.cummax

Examples

>>> df = ps.DataFrame(
...     [[1, None, 4], [1, 0.1, 3], [1, 20.0, 2], [4, 10.0, 1]],
...     columns=list('ABC'))
>>> df
   A     B  C
0  1   NaN  4
1  1   0.1  3
2  1  20.0  2
3  4  10.0  1

By default, iterates over rows and finds the sum in each column.

>>> df.groupby("A").cummax().sort_index()
      B  C
0   NaN  4
1   0.1  4
2  20.0  4
3  10.0  1

It works as below in Series.

>>> df.C.groupby(df.A).cummax().sort_index()
0    4
1    4
2    4
3    1
Name: C, dtype: int64