I have a pandas dataframe which looks like this,
ID t_payment t_process t_service t_others
1 0 1 1 0
2 1 0 0 0
3 0 1 1 1
4 1 1 1 1
5 1 1 0 0
I am trying to convert this to single variable and the output should look like this,
ID category
1 process,service
2 payment
3 process,service,others
4 payment,process,service,others
5 payment,process
How can i do this? I can use if else logic, but i have more than 8 columns, covering all the possible combination looks tedious, is there any other approach?
Thanks in advance.
EDIT : Whoever closed this as a duplicate, it is not the same as the other question. Here I have multiclasses, if you look at first record for example, both t_process & t_service is true. However in the question you pointed, only one class is true for a row. Also here there is an ID column.