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
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