Reputation: 7329
I know this way works, but is there a more standard way of doing this?
N=1
cols = list(data.iloc[:,(data.max()==1).values].columns)
Upvotes: 1
Views: 40
Reputation: 19634
This will do the job:
df=pd.DataFrame({'a':[1,-1],'b':[3,4]})
df.columns[df.max()==1].tolist()
This prints ['a']
Upvotes: 1