I have a dataframe:
id type1 type2 val
a main regular 3
a main unregular 5
a main large 3
b second regular 80
b second unregular 90
I want to do groupby by columns id type1 and max() by val. but when I do that:
df.groupby(["id","type1"])["val"].max().reset_index()
I get:
id type1 val
a main 5
b second 90
But I want:
id type1 type2 val
a main unregular 5
b second unregular 90
How to do that?