I have a DataFrame like this:
DataFrame
df:
df
fruit val1 val2 0 orange 15 3 1 apple 10 13 2 mango 5 5 >
fruit val1 val2 0 orange 15 3 1 apple 10 13 2 mango 5 5
df['cum_sum'] = df['val1'].cumsum() df['cum_perc'] = 100*df['cum_sum']/df['val1'].sum()
This will add the columns to df. If you want a copy, copy df first and then do these operations on the copy.