
The cumprod() method in pandas return the cumulative product over a DataFrame or Series axis. Each cell is populated with the cumulative product of the values seen so far.
Syntax –
DataFrame.cumprod(axis=None, skipna=True, *args, **kwargs)
Examples –
Let’s create a dataframe to work with.
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3, 4, 5],
'B': [6, 7, 8, 9, 10]})
df

1 . find the cumulative product of the values seen so far along the index axis –
By default cumprod() method find the cumulative product of the value seen so far in a column. You can also set it explicitly by setting the axis parameter to axis=0 or index.
df.cumprod(axis=0)

2 . Find the cumulative product of the values seen so far along the column axis –
To find the cumulative product of the value seen so far in a row we set the axis parameter to axis=1 or columns.
df.cumprod(axis=1)
