I have a df structured in following setting and would like to change it so that the types found in the column type
are the the row readers with the original result
as the row the new type column, condensing all ids
into one row. For example, I would like to change the following table:
id | name | type | result |
---|---|---|---|
A | Apple | 1 | X |
A | Apple | 2 | X |
A | Apple | 3 | X |
B | Banana | 1 | Y |
B | Banana | 2 | Y |
C | Cantaloupe | 2 | Z |
C | Cantaloupe | 3 | Z |
... | ... | ... | ... |
To:
id | name | 1 | 2 | 3 |
---|---|---|---|---|
A | Apple | X | X | X |
B | Banana | Y | Y | None |
C | Cantaloupe | None | Z | Z |
... | ... | ... |