So, I have a dataset:
foo bar baz
--- --- ---
one A 1
one B 2
one B 3
two A 4
two B 5
two C 6
I want to get such table:
foo A B C
--- - - -
one 1 5 0
two 4 5 6
And by using:
df.pivot(index='foo', columns='bar', values='baz')
I am getting such error:
ValueError: Index contains duplicate entries, cannot reshape
How I can sum duplicate elements in pivot? Or maybe there is another command for such manipulations?