My date in my column looks like this:
Date |
---|
9999-12-31 00:00:00 |
I want to covert the type of the column Date to datetime.
Because i have a time in the column with 00:00:00 i can’t use the function to_datetime[‘Date’]. If i use the to_datatime[‘date’] it will give me an error.
I know that you can add errors =coerce
and then it will give NaT
values back and is not what i want.
i wrote a small function below which keeps my original values. i it’s not converting to the type = datetime
adr_df['HIS_TS_END'] = adr_df['HIS_TS_END'].apply(lambda x: datetime.datetime.strptime(x,'%Y-%m-%d %H:%M:%S.%f') if type(x)==str else pd.NaT)
print(type(adr_df.iloc[0][1]))
What do i need to add so my datatype will be datetime
?
3