You can use the cummax() of the Pandas. It returns a cumulative maximum over a DataFrame or Series axis.
Here is an example:
>>> import pandas as pd>>> df = pd.DataFrame({'A':[1,4,3,2,5], 'B':[10,23,11,12,25]})>>> df.cummax(axis=1) A B0 1 101 4 232 3 113 2 124 5 25>>> df.cummax(axis=0) A B0 1 101 4 232 4 233 4 234 5 25>>>