I have a pandas dataframe with three columns:
Name Name2 DateTime
2016-06-10 05:22
2016-06-10 05:23
2016-06-10 14:25
Guest Guest1 2016-06-10 15:32
I have to replace empty spaces with NAN. So AccountName and AccountName2 of rows 1,2,3 and 4 should be NAN. I tried the below statement:
df3['Name'] = df3['Name'].replace(r'[^\s+]',np.nan, regex=True)
But since I have white spaces after "Guest " in Name, all 5 rows get replaced with NAN.
Edit:
This is our actual data.
Name Name2 DateTime
\t\t-\r\n\t \t\t-\r\n\t 2016-06-10 05:22
\t\t-\r\n\t \t\t-\r\n\t 2016-06-10 05:23
\t\t-\r\n\t \t\t-\r\n\t 2016-06-10 14:25
\t\tGuest\r\n\t \t\tGuest1\r\n\t 2016-06-10 15:32
I used this to remove those escape characters.
df['Name'] = df['Name'].str.replace('\r','').str.replace('\t','').str.replace('\n','').str.replace('-','')
After removing those characters, I am not sure what gets inserted in that place now.