# Convert a pandas column of int to timestamp datatype

I have a dataframe that among other things, contains a column of the number of milliseconds passed since 1970-1-1. I need to convert this column of ints to timestamp data, so I can then ultimately convert it to a column of datetime data by adding the timestamp column series to a series that consists entirely of datetime values for 1970-1-1.

I know how to convert a series of strings to datetime data (pandas.to_datetime), but I can't find or come up with any solution to convert the entire column of ints to datetime data OR to timestamp data.

You can specify the unit of a pandas to_datetime call.

Stolen from here:

# assuming df is your data frame and date is your column of timestamps

df['date'] = pandas.to_datetime(df['date'], unit='s')


Should work with integer datatypes, which makes sense if the unit is seconds since the epoch.

• what's the revers function? Jan 22 '19 at 15:51
• @FrancescoBoi to_timedelta Sep 29 '20 at 6:00