I am learning pivots and pivot tables in pandas. Below is a practice code I got from a video.
df = pd.DataFrame({'foo': ['one', 'one', 'one','two','two','two'],
'bar': ['A','B','C','A','B','C'],
'baz': [1,2,3,4,5,6],'zoo':['x','y','z','q','w','t']})
df.pivot('foo', 'bar', 'baz')
When I try apply this to my personal data I get the follwoing error:
ValueError: Index contains duplicate entries, cannot reshape
This is confusing because the practice code also has duplicate indexes, but I don't an error.
Can someone explain to me why?