0 points

Convert column with datetime to timestamp integer and remove milliseconds


PHOTO EMBED

Wed Feb 03 2021 14:38:40 GMT+0000 (UTC)

Saved by @fre_apples #python

data_copy["ts"] = data_copy["effective_to_date"].astype("int64")/1e9 
data_copy["ts"].iloc[1]
# the division exclude milliseconds bringing it down to seconds
content_copyCOPY

It worked for me starting from a copy of my original data (data_copy) and I used it before dummifying my data before train-test split, that way my column with date is converted in epoch https://www.epochconverter.com/