I have a dataframe with several columns showing percentage distributions.
I used df["MaxColumn"] = df.idxmax(axis=1) to identify the name of the column with the largest number for each row.
Now I need to do more calculations, i.e. add 1 to the cell with max value in each row.
I assumed that I could do something like df[df["MaxColumn"]] += 1, but I'm getting errors.
My dataframe:
Level1 Level2 Level3 MaxColumn
1 0.5 0.3 0.1 Level1
2 0.2 0.1 0.6 Level3
What I want is to add 1 to the max value in each row and get this:
Level1 Level2 Level3 MaxColumn
1 1.5 0.3 0.1 Level1
2 0.2 0.1 1.6 Level3