Pandas.DataFrame.cummax() Function with Example | 2019

Spread the love

Syntax: DataFrame.cummax (axis=None, skipna=True, *args, **kwargs)

This function return cumulative maximum over a DataFrame or Series axis.

Parameters:
axis : {0 or ‘index’, 1 or ‘columns’}, default 0
The index or the name of the axis. 0 is equivalent to None or ‘index’.

skipna : boolean, default True
Exclude NA/null values. If an entire row/column is NA, the result will be NA.

*args, **kwargs :
Additional keywords have no effect but might be accepted for compatibility with NumPy.

Returns:
cummax : Series or DataFrame

import numpy as np import pandas as pd df = pd.DataFrame({'A': [3,5, 2], 'B': [4, 6, 8], 'C':[9,10,11]}) print(df.cummax()) print("with axis =1\n",df.cummax(axis=1))

Output:

   A  B   C
0  3  4   9
1  5  6  10
2  5  8  11
with axis =1    
   A  B   C
0  3  4   9
1  5  6  10
2  2  8  11

 

admin

admin

Leave a Reply

Your email address will not be published. Required fields are marked *