Issue
My data looks like this:
First_Name Middle_Name Last_Name Full_Name (Header)
John R Rovin John R Rovin
Marano Justine Marano nan Justine
David Rose David nan Rose
nan nan nan
Robert Robert nan nan
I am trying to trim nan from Full_Name column to just get whatever name it possibly contains as is. When I am trying to use Fillna(‘ ‘) , its not helping me to trim but its completely removing the column content. My final DF should look something like this:
First_Name Middle_Name Last_Name Full_Name (Header)
John R Rovin John R Rovin
Marano Justine Marano Justine
David Rose David Rose
Robert Robert
I am heavily dependent for most of the operations on Pandas. So is there any way using pandas I can solve this problem?
Solution
if nan
always appear the same in Full_Name
column you can use this:
df['Full_Name (Header)'] = df['Full_Name (Header)'].str.replace('nan', ' ')
Answered By – Ali Halataee
Answer Checked By – Candace Johnson (BugsFixing Volunteer)