Find the row which has the maximum difference between two columns
Instead of .where
, you can use .idxmax
:
(df['Gold'] - df['Gold.1']).idxmax()
Out: 6
This will return the index where the difference is maximum.
If you want to find the row with the maximum absolute difference, then you can call .abs()
first.
(df['Gold'] - df['Gold.1']).abs().idxmax()
Out: 4