pandas.DataFrame.cumsum() function with example

Spread the love

DataFrame.cumsum()Function : This function return cumulative sum over a DataFrame or Series axis.

Syntax: DataFrame.cumsum(axis=None, skipna=True, *args, **kwargs):

axis : {0 or ‘index’, 1 or ‘columns’}, default 0
The index or the name of the axis. 0 is equivalent to None or ‘index’.

skipna : boolean, default True
Exclude NA/null values. If an entire row/column is NA, the result will be NA.

*args, **kwargs :
Additional keywords have no effect but might be accepted for compatibility with NumPy.

cumsum : Series or DataFrame

#python example program on pandas.dataframe.cumsum() function

import numpy as np import pandas as pd df = pd.DataFrame({'A': [1,2,3], 'B': [4, 6, 9], 'C':[9,10,12]}) print(df.cumsum()) print("with axis =1\n",df.cumsum(axis=1))





Leave a Reply

Your email address will not be published. Required fields are marked *