I have the following code:
df["date"] = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
df['date'] = pd.to_datetime(df['date'])
It takes 2020-04-29 14:12:32.692683
convert it to String of 2020-04-29 14:12:32
and then set it up as TIMESTAMP type.
i remove the milliseconds as they are not needed.
It works well but the idea of timestamp -> string -> timestamp sounds very inefficient.
I must have the date column as TIMESTAMP type because it's being added to database and this is the only way that the database will recognise it as TIMESTAMP type rather than VARCHAR
Is there a better way to do this?