I have a dataframe:
id info
1 Name: John Age: 12 Sex: Male
2 Name: Sara Age: 22 Sex: Female
3 Name: Mac Donald Age: 32 Sex: Male
I'm looking to split the info column into 3 columns such that i get the final output as:
id Name Age Sex
1 John 12 Male
2 Sara 22 Female
3 Mac Donald 32 Male
I tried using pandas split function.
df[['Name','Age','Sex']] = df.info.split(['Name'])
I might have to do this multiple times to get desired output.
Is there a better way to achieve this?
PS: The info column also contains NaN values