I have this df:
A B C D a d a z b c z c My goal is to pull out the column names where df == 'z' so I used:
df['ColumnNames'] = df.where(df=='z' ).stack().reset_index().groupby('level_0')['level_1'].apply('+ '.join) It used to work fine; however today I got an error saying: "TypeError: Could not compare ['z'] with block values"
Does anyone know why this happens? Many thanks!
inttostr. Trydf.astype(object) == 'z'