Basically, I have a pandas dataframe where a column is a string of dates. I want to transform each value into datetime so I can look for a specific value there later, like this:
df = pd.DataFrame({'DATESTAMP': ['01/01/2017','02/01/2017','03/01/2017']})
df['DATESTAMP2']=pd.to_datetime(df['DATESTAMP'])
date = datetime.strptime('02/01/2017', '%d/%m/%Y')
date in df['DATESTAMP2']
False
As you can see, it doesn't detect the date. I checked why, and I found that the format of the new DATESTAMP2 column is
df['DATESTAMP2']
Out[296]:
0 2017-01-01
1 2017-01-02
2 2017-01-03
Name: DATESTAMP2, dtype: datetime64[ns]
df['DATESTAMP2'][2]
Out[279]: Timestamp('2017-01-03 00:00:00')
This is not datetime, it's a timestamp, which makes sense that it wouldn't be able to compare it with the date var.
Is there a way to solve this, aka to actually convert the column to datetime and not timestamp?