Jan-07-2019, 01:06 PM
Hi,
I have below DataFrame:
I have below DataFrame:
A 1.2 3.6 B 2.6 3.8 A 1.5 2.1 B 2.0 2.9 C 2.4 3.5 H 4.1 2.9 C 5.9 9.3 A 2.9 8.3 B 8.7 5.6 H 2.9 7.3 H 3.6 1.9 B 2.3 1.0 A 7.1 2.3I use blow code:
import pandas as pd d = {'col1': ['B','A','B','C','H','C','A','B','H','H','B','B'],'col2': [2.6,1.5,2.0,2.4,4.1,5.9,2.9,8.7,2.9,3.6,2.3,2.3], 'col3': [3.8,2.1,2.9,3.5,2.9,9.3,8.3,5.6,7.3,1.9,1,1]} df = pd.DataFrame(data=d) df_avg=df.groupby(['col1']).mean() # this line works df_pct=df.groupby(['col1']).pct_change.sum()AttributeError: 'function' object has no attribute 'sum'