where I have found this option in other languages such as R or SQL but I am not quite sure how to go about this in Pandas.
So I have a file with 1262 columns and 1 row and need the column headers to return for every time that a specific value appears.
Say for example this test dataframe:
Date col1 col2 col3 col4 col5 col6 col7
01/01/2016 00:00 37.04 36.57 35.77 37.56 36.79 35.90 38.15
Seeing as you only have a single row then you can call
iloc on the result and use this to mask the columns:
In : df.columns[(df == 38.15).iloc] Out: Index(['col7'], dtype='object')
Breaking down the above:
In : df == 38.15 Out: Date col1 col2 col3 col4 col5 col6 col7 01/01/2016 False False False False False False False True In : (df == 38.15).iloc Out: Date False col1 False col2 False col3 False col4 False col5 False col6 False col7 True Name: 01/01/2016, dtype: bool
You can also use
idxmax with param
In : (df == 38.15).idxmax(axis=1) Out: 'col7'