I have a large dataset with about 50 columns, but the columns of concern are listed below:
| ID | category | price | code |
|---|---|---|---|
| 11 | A | 10 | 1 |
| 12 | B | 5 | 22 |
| 12 | A | 9 | 26 |
| 25 | B | 13 | 17 |
| 26 | A | 8 | 19 |
| 26 | B | 11 | 6 |
As you can see, some of my IDs have both categories A and B and some don’t. In my output table I want each ID to have both categories A and B and “blank” cells for missing prices and codes in the newly added rows. My desired output looks like this:
| ID | category | price | code |
|---|---|---|---|
| 11 | A | 10 | 1 |
| 11 | B | ||
| 12 | A | 9 | 26 |
| 12 | B | 5 | 22 |
| 25 | A | ||
| 25 | B | 13 | 17 |
| 26 | A | 8 | 19 |
| 26 | B | 11 | 6 |
Any ideas would be appreciated.