Closed
Description
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 "<ipython-input-6-ba00dea82129>", line 1, in <module>
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 line
offset = tslib.Timestamp(origin) - tslib.Timestamp(0)
Should this be allowed?