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
走同樣的路,發(fā)現(xiàn)不同的人生
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()
At least one reassignment is needed to extract these three columns. The grouping method seems to be like yours