I have a dataframe in pandas that gives you the below table:
I would like to get the below results by summing up the calls and getting the type in one single line. (you can observe the yellow rows)
CodePudding user response:
Try:
# aggregate by Key
# keep the first No, join types, and sum calls
df.groupby("Key", as_index=False).agg({"No": "first", "Type": "; ".join, "Calls": "sum"})