How to reshape dataframe if they have same index?

Viewed 296

If I have a dataframe like

df= pd.DataFrame(['a','b','c','d'],index=[0,0,1,1])
   0
0  a
0  b
1  c
1  d

How can I reshape the dataframe based on index like below i.e

df= pd.DataFrame([['a','b'],['c','d']],index=[0,1])
  0  1
0  a  b
1  c  d
3 Answers
Related