I want to reorganize my pandas dataframe.
Currently my dataframe looks like this:
Name | C | Nr | Value | R |
---|---|---|---|---|
1 | B | 1 | 1.1 | p |
1 | B | 2 | 1.3 | p |
1 | G | 1 | 2.4 | p |
1 | G | 2 | 2.5 | p |
2 | B | 1 | 4.4 | n |
2 | B | 2 | 8.0 | n |
2 | G | 1 | 8.1 | n |
2 | G | 2 | 7.0 | n |
3 | B | 1 | 9.2 | p |
3 | G | 1 | 6.5 | p |
and i want my dataframe to look like this
ID | B1 | B2 | G1 | G2 | R |
---|---|---|---|---|---|
1 | 1.1 | 1.3 | 2.4 | 2.5 | p |
2 | 4.4 | 8.0 | 8.1 | 7.0 | n |
3 | 9.2 | N/A | 6.5 | N/A | p |
So far i was not able to find a combination of groupby stack unstack to solve this problem.
Do you have any ideas?
The real dataframe is much bigger with ~10000 rows and the desired dataframe would have 800 columns