2

I have a dataframe with 8000 columns and 37605 rows, I want to merge the same column names and sum the values, but as you can see the columns have a subindex(I don't know the name), the difference between X98598.1 and X98598. that I think cause me a problem. This is a part of the df

X98595      X98596      X98597      X98597.1    X98598      X98598.1
-0.460291   1.112228    -0.797426   -1.223580   -0.347824  -0.126443     
 0.233851   0.001305    -0.572343   -0.312111   -0.192996  -0.643598     
 0.003458  -1.068415    1.284535    -0.924175   -0.379626  -0.021685
 1.904167  -0.400165    -0.440025   -0.638341   -0.637231  -0.347531    

and I've tried with this code

df.groupby(df.columns, axis=1).sum()

but doesn't work, do you have any idea? Please

0 Answers0