I was hoping someone could help me convert my current dataframe from a wide to long format. I am using Pandas 0.18.0 and I can't seem to find any other solution on stackoverflow that fits my need.
Any help would be greatly appreciated!
I have 50 steps each with two categories(status/time) that I need to melt, these categories alternate in my dataframe. Below is an example with only 3 sets but this pattern continues until it reaches 50.
status can be either: yes/no/NaN
time can be either: timestamp/NaN
Current Dataframe:
cl_id cl_template_id status-1 time-1 status-2 time-2 status-3 time-3
0 18434 107 NaN NaN NaN NaN NaN NaN
1 18280 117 yes 2016-12-28T18:21:58+00:00 yes 2016-12-28T20:47:31+00:00 yes 2016-12-28T20:47:32+00:00
2 18356 413 yes 2017-01-11T19:23:10+00:00 yes 2017-01-11T19:23:11+00:00 yes 2017-01-11T19:23:11+00:00
3 18358 430 NaN NaN NaN NaN NaN NaN
4 18359 430 yes 2017-01-11T19:20:32+00:00 yes 2017-01-11T19:20:34+00:00 NaN NaN
.
.
.
Target Dataframe:
cl_id cl_template_id step status time
18434 107 1 NaN NaN
18434 107 2 NaN NaN
18434 107 3 NaN NaN
18280 117 1 yes 2016-12-28T18:21:58+00:00
18280 117 2 yes 2016-12-28T20:47:31+00:00
18280 117 3 yes 2016-12-28T20:47:32+00:00
18356 413 1 yes 2017-01-11T19:23:10+00:00
18356 413 2 yes 2017-01-11T19:23:11+00:00
18356 413 3 yes 2017-01-11T19:23:11+00:00
.
.
.