'Break down column to row values [duplicate]

I have a data frame where I have a column named B which has apples and oranges as the data. How can I basically transform these values as separate columns in the same data frame.

Below is my code-

s={'A':[1,1,2,2],'B':['Apples','Oranges','Apples',"Oranges"],'C':[2014,2014,2016,2016],'value':[2,3,4,5]}
p=pd.DataFrame(data=s)

The O/p should be column with A, Apples, Oranges, C

enter image description here

How can I get this requirement done?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source