python pandas cumulative return

#We calculate and plot the cumulative return of a given dataframe called data
r = data.pct_change()  
r_plus_one = r.add(1)
cumulative_return = r_plus_one.cumprod().sub(1)
plt.legend(['Cumulative Return'])

Here is what the above code is Doing:
1. We calculate the percent change of the dataframe data.
2. We add 1 to the percent change.
3. We calculate the cumulative product of the percent change plus 1.
4. We subtract 1 from the cumulative product.
5. We multiply the result by 100.
6. We plot the result.