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