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)
cumulative_return.mul(100).plot()
plt.ylabel('Percent')
plt.legend(['Cumulative Return'])
plt.show()

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.