-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
The constructor for pd.Timestamp has both a tz= and tzinfo= argument, presumably because pd.Timestamp is trying to both support the datetime.datetime interface and its own constructor. There is evidently logic in the constructor to prevent both tz and tzinfo being specified, but it seems something has gone wrong, because constructing an aware pd.Timestamp by components and including tzinfo always raises an exception, see:
import pandas as pd
from datetime import timezone
pd.Timestamp(2020, 1, 1, tzinfo=timezone.utc)This raises the following exception:
>>> pd.Timestamp(2020, 12, 31, tzinfo=timezone.utc)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-18-9d882de0a384> in <module>
----> 1 pd.Timestamp(2020, 12, 31, tzinfo=timezone.utc)
pandas/_libs/tslibs/timestamps.pyx in pandas._libs.tslibs.timestamps.Timestamp.__new__()
ValueError: Can provide at most one of tz, tzinfo
Despite the fact that only tzinfo was specified. This seems to only occur when you are using the "per-component" specification, as passing a datetime or epoch time as the first component allows you to specify the time zone using tzinfo:
pd.Timestamp(0, tzinfo=timezone.utc) # Works