In python3 and pandas I have a dataframe with dates as an integer that represents the amount of milliseconds since Jan 1, 1970 00:00:00 UTC
presidentes["Data distribuição"].head()
0 1367193600000.0
1 1252886400000.0
2 1063929600000.0
3 1196294400000.0
4 1254873600000.0
Name: Data distribuição, dtype: object
I want to convert to datatype timestamp and tried like this
presidentes['Data distribuição'] = pd.to_datetime(presidentes['Data distribuição'], unit='s')
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_with_unit_to_datetime()
pandas/_libs/tslibs/timedeltas.pyx in pandas._libs.tslibs.timedeltas.cast_from_unit()
OverflowError: Python int too large to convert to C long
During handling of the above exception, another exception occurred:
OutOfBoundsDatetime Traceback (most recent call last)
<ipython-input-10-53c23a37f5b2> in <module>
----> 1 presidentes['Data distribuição'] = pd.to_datetime(presidentes['Data distribuição'], unit='s')
~/Documentos/Code/publique_se/lib/python3.6/site-packages/pandas/core/tools/datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, box, format, exact, unit, infer_datetime_format, origin, cache)
590 else:
591 from pandas import Series
--> 592 values = convert_listlike(arg._values, True, format)
593 result = Series(values, index=arg.index, name=arg.name)
594 elif isinstance(arg, (ABCDataFrame, compat.MutableMapping)):
~/Documentos/Code/publique_se/lib/python3.6/site-packages/pandas/core/tools/datetimes.py in _convert_listlike_datetimes(arg, box, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
201 arg = getattr(arg, 'values', arg)
202 result = tslib.array_with_unit_to_datetime(arg, unit,
--> 203 errors=errors)
204 if box:
205 if errors == 'ignore':
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_with_unit_to_datetime()
OutOfBoundsDatetime: cannot convert input 1367193600000.0 with the unit 's'
Please is there any other way to perform this conversion?