Given a df:
Date1 Text1
2018-03-20 00:00:00 abc
2018-04-01 00:00:00 abc
2018-01-01 00:00:00 abc
2018-04-01 00:00:00 xyz
abc
My goal to add a new column where: if text = "abc" and Date1 is with 90 days from now then "New" The output would be:
Date1 Text1 NewText
2018-03-20 00:00:00 abc New
2018-04-01 00:00:00 abc New
2018-01-01 00:00:00 abc
2018-04-01 00:00:00 xyz
abc
This is what I have:
days90 = date.today() - timedelta(90)
df['NewText'] = np.where(df['Text1'] = "abc" & df['Date1'] < pd.to_datetime(days90), "New", np.nan)
However, I'm keep running into errors.
AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas
Any suggestion? Many thanks!