df = df.groupby(['A','B'])['c'].mean()
In this way, df is grouped, but how to turn df into a dataframe with columns A, B, and C?
Thanks
为情所困2017-05-24 11:37:08
I asked this question on stackoverflow, and some netizens gave me the answer. In fact, you only need to add one parameter. The method is as follows:
df = df.groupby(['A','B'],as_index = False)['C'].mean()
習慣沉默2017-05-24 11:37:08
At least one reassignment is needed to extract these three columns. The grouping method seems to be like yours