0
私は多数のデータフレームを持っています。私は関数を適用したいです。私がしようとしていますgroupbyを適用する関数
Year ID Pressure
1984 1 0.2
1985 2 0.5
1986 3 0.7
:
私のデータフレームは、次のようになり
def f(x):
return x.groupby(['ID']).Pressure.mean().to_frame().reset_index()
#apply the function to dataframes
df.apply(f)
df2.apply(f)
これが返されます。
KeyError: ('ID', u'occurred at index Year')
を私にできる機能せず、私はこのように何をしたいです:
df=df.groupby(['ID']).Pressure.mean().to_frame().reset_index()