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
走同样的路,发现不同的人生
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
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:
At least one reassignment is needed to extract these three columns. The grouping method seems to be like yours