0

In my dataframe there are duplicates in the index. How can I remove those duplicates in the index and have the data just in one row? So the start can be seen in screenshot 1, the aim in 2.

Start Aim

wwii
  • 23,232
  • 7
  • 37
  • 77
newcomer
  • 35
  • 4
  • 1
    Please don’t post images of code, data or Tracebacks. Copy and paste it as text then format it as code (select it and type `ctrl-k`). [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – wwii Dec 11 '22 at 13:56

1 Answers1

0

Assuming df is your dataframe, you can use GroupBy.sum on level=0:

out = df.groupby(level=0, sort=False).sum()

# Output :

print(out)

           A     B
weight  0,05  0,04
size    0,02  0,01
Timeless
  • 22,580
  • 4
  • 12
  • 30