I have a dataframe df created as,
df = pd.DataFrame([
[0, 1, 0],
[1, 0, 0],
[0, 1, 0]],
columns=['Mon','Tue','Wed'])
df:
Mon Tue Wed
0 0 1 0
1 1 0 0
2 0 1 0
For this dataframe, I want to replace the element '1'- to the respective column name and '0' to be replaced with- "", and finally combine all of them.
1 and 0 can also be characters- 'X' and '-'.
Desired Output:
Day
0 Tue
1 Mon
2 Tue