I have a dataframe in pandas of the sort
df = pd.DataFrame({
"id": [1, 1, 1, 1, 2, 2, 2, 2],
"column": ["a", "b","a", "b", "a", "b", "a", "b"],
"value": [1, 7, 6, 5, 4, 3, 1, 7]
})
I want to generate a new dataframe where we have
id | value_a | value_b |
---|---|---|
1 | 1 | 7 |
1 | 6 | 5 |
2 | 4 | 3 |
2 | 1 | 7 |
I tried many things, pivot, pivot table and so on, but all solutions seem to need index column which gets unique and the values being aggregated in some way. I want keep repeating id and have the values in the original order they appeared.
Thanks in advance!