I have a dataframe like :
A B C 1 0 0 1 1 0 0 1 0 0 0 1
I want to have :
A B C lab
Here is an idiomatic and performant solution
df['label'] = np.where(df, df.columns, '').sum(axis=1) A B C label 0 1 0 0 A 1 1 1 0 AB 2 0 1 0 B 3 0 0 1 C