Examples
import numpy as np
import pandas as pd
df = pd.DataFrame([[3.0, 2.0],
                   [4.0, np.nan],
                   [2.0, 0.0]],
                   columns=list('XY'))
df
By default, iterates over rows and finds the maximum in each column:
df.cummax()
To iterate over columns and find the maximum in each row, use axis=1:
df.cummax(axis=1)