Cannot use tz-aware origin in to_datetime() · Issue #16842 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
import pandas as pd pd.version '0.20.2' from datetime import datetime, timezone pd.to_datetime(1, unit='D', origin=datetime(2000, 1, 1)) Timestamp('2000-01-02 00:00:00') pd.to_datetime(1, unit='D', origin=datetime(2000, 1, 1, tzinfo=timezone.utc)) Traceback (most recent call last): File "C:\Users\mchivers\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in pd.to_datetime(1, unit='D', origin=datetime(2000, 1, 1, tzinfo=timezone.utc)) File "C:\Users\mchivers\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\tools\datetimes.py", line 487, in to_datetime offset = tslib.Timestamp(origin) - tslib.Timestamp(0) File "pandas_libs\tslib.pyx", line 1244, in pandas._libs.tslib._Timestamp.sub (pandas_libs\tslib.c:23487) TypeError: Timestamp subtraction must have the same timezones or no timezones
Problem description
Attempting to use a timezone aware origin argument in pandas.to_datetime()
causes an error due to the lineoffset = tslib.Timestamp(origin) - tslib.Timestamp(0)
Should this be allowed?