I have a pandas data frame with the following format:
CALL_SIGN | NB_TRX | CH1 | CH2 | ... | CH16 |
---|---|---|---|---|---|
abcd | 8 | 300 | 301 | ... | 301 |
bdfe | 8 | 312 | 313 | ... | 301 |
aedf | 16 | 302 | 302 | ... | 302 |
fwee | 16 | 350 | 354 | ... | 354 |
And I want to separate the column CH1 to CH16 into multiple rows keeping the info of CALL_SIGN and NB_TRX
CALL_SIGN | NB_TRX | CH |
---|---|---|
abcd | 8 | 300 |
abcd | 8 | 301 |
... | ... | ... |
bdfe | 8 | 312 |
bdfe | 8 | 313 |
... | ... | ... |
fwee | 16 | 354 |
I was able to do it with some loops but I am wondering if there is a way to avoid the loops. What would be the best way to do this task?