pandas.DataFrame.compound() function with example

Spread the love

pandas.DataFrame.compound(): This function return the compound percentage of the values for the requested axis.

Syntax: DataFrame.compound(axis=None, skipna=None, level=None)

axis : {index (0), columns (1)}
Axis for the function to be applied on.

skipna : bool, default True
Exclude NA/null values when computing the result.

level : int or level name, default None
If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a Series.

numeric_only : bool, default None
Include only float, int, boolean columns. If None, will attempt to use everything, then use only numeric data. Not implemented for Series.

Additional keyword arguments to be passed to the function.

compounded : Series or DataFrame (if level specified)

pandas.DataFrame.compound() function example :

import pandas as pd df = pd.DataFrame({'A': [5, 2], 'B': [4, 8]}) print(df.compound())


A    17
B    44
dtype: int64






Leave a Reply

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