I have a dataframe with duplicates, and I would like for a given column to sum the values of the duplicates and for another column calculate the mean of the duplicates. The picture below illustrates what I want to achieve.
I would like something this
df1.groupby(["A", "B"], as_index=False){"C": sum ,"D": mean}
I checked this solution Apply multiple functions to multiple groupby columns but the output structure is not what I want.
Any help would be appreciated.