I have a dataframe that has column 'name'. With values like 'James Cameron'. I'd like to split it out into 2 new columns 'First_Name' and 'Last_Name', but there is no delimiter in the data so I am not quite sure how. I realize that 'James' is in position [0] and 'Cameron' is in position [1], but I am not sure you can recognize that without the delimiter
df = pd.DataFrame({'name':['James Cameron','Martin Sheen'],
'Id':[1,2]})
df
EDIT:
Vaishali's answer below worked perfectly, for the dataframe I had provided. I created that dataframe as an example though. My real code looks like this"
data[['First_Name','Last_Name']] = data.director_name.str.split(' ', expand = True)
and that unfortunately, is throwing an error:
'Columns must be same length as key'
The column holds the same values as my example though. Any suggestions?
Thanks