given a data frame with one descriptive column and X numeric columns, for each row I'd like to identify the top N columns with the higher values and save it as rows on a new dataframe.
For example, consider the following data frame:
df = pd.DataFrame()
df['index'] = ['A', 'B', 'C', 'D','E', 'F']
df['option1'] = [1,5,3,7,9,3]
df['option2'] = [8,4,5,6,9,2]
df['option3'] = [9,9,1,3,9,5]
df['option4'] = [3,8,3,5,7,0]
df['option5'] = [2,3,4,9,4,2]
I'd like to output (lets say N is 3, so I want the top 3):
A,option3
A,option2
A,option4
B,option3
B,option4
B,option1
C,option2
C,option5
C,option4 (or option1 - ties arent really a problem)
D,option5
D,option1
D,option2
and so on....
any idea how that can be easily achieved? Thanks