0

I have a dataframe with a date column but some values are blank or NaN, I am trying to replace all these values with a date from another column. I am trying the solution below but its not working, can someone please help

df['Date'] = df['Date'].replace(np.nan, df['Date2'])
Samir112
  • 125
  • 1
  • 12

1 Answers1

0

some values are blank or NaN

You can first replace empty strings with NaN with replace then use fillna.

Try this :

df['Date'] = df['Date'].replace("", np.NaN).fillna(df['Date2'])
Timeless
  • 22,580
  • 4
  • 12
  • 30