Convert date from int64 to datetime

Viewed 11069

I have an int64 object in a pandas data frame and that is supposed to represent a date.

>>> df.dtypes
CreatedDate              int64

Obviously, I want to convert this into a date time, so I did the following

df["CreatedDate2"] = pd.to_datetime(pd.Series(df["CreatedDate"]))

>>> df[["CreatedDate","CreatedDate2"]].head()
     CreatedDate               CreatedDate2
0  1466461661000 1970-01-01 00:24:26.461661
1  1464210703000 1970-01-01 00:24:24.210703
2  1423576093000 1970-01-01 00:23:43.576093
3  1423611903000 1970-01-01 00:23:43.611903
4  1423617600000 1970-01-01 00:23:43.617600
>>> 

However, this is producing dates that are in the 1970s, which shouldn't be true. Can anyone tell me how to convert int64 to datetime in a pandas data frame. I thought this was the right way.

2 Answers
Related