I have this dataframe:
| id1 | id2 | code |
|---|---|---|
| 1234 | qw123 | 4h2 |
| 5678 | de121 | 23f |
| 9012 | - | 64r |
The desired output is:
| id1 | code |
|---|---|
| 1234 | 4h2 |
| qw123 | 4h2 |
| 5678 | 23f |
| de121 | 23f |
| 9012 | 64r |
I'm trying to kind of melt/concat the id2 column to id1 and keep its value from id correspondingly, so at the end I can have one column with ids and one column with codes.
Also is it possible to make the code generic, in order to not hard code the names of the id columns, because there could be a possibility that the id columns could be 2 or 3?
I'd appreciate any kind of help! Thanks