I am not going to pretend these are the most efficient way of dealing with this problem, but I though they are worth mentioning:
df
A B C D E F
1 0 1 2 3 4 5
2 6 7 8 9 10 11
3 12 13 14 15 16 17
4 18 19 20 21 22 23
5 24 25 26 27 28 29
Using df.max()
to get the maximum value of each column and then sorting values and getting the biggest numbers. Then masking them against the original df and returning the values. A list comprehension can is finally used to get the indices:
df_2 = df[df.max().sort_values(ascending=True).tail(3).eq(df)]
[(i, df_2[i].first_valid_index()) for i in df_2.columns if df_2[i].first_valid_index() != None]
Output:
[('D', 5), ('E', 5), ('F', 5)]
or
s = df_2.apply(pd.Series.first_valid_index).dropna()
list(zip(s.index, s.astype(int)))
Output:
[('D', 5), ('E', 5), ('F', 5)]