Pandasのgroupbyの結果をDateFrameにする
groupbyでは、groupieオブジェクトが返却されるが、DataFrameが欲しいときがある。その場合は、as_index=Falseを指定する。
In [70]: type(df.groupby(['項目1','項目2'],as_index=False).agg(np.average)) Out[70]: pandas.core.frame.DataFrame
groupbyでは、groupieオブジェクトが返却されるが、DataFrameが欲しいときがある。その場合は、as_index=Falseを指定する。
In [70]: type(df.groupby(['項目1','項目2'],as_index=False).agg(np.average)) Out[70]: pandas.core.frame.DataFrame