You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 tzinfoalways raises an exception, see:
>>> 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
The text was updated successfully, but these errors were encountered:
pganssle
changed the title
pd.Timestamp constructor fails if tzinfo is specified
BUG: pd.Timestamp constructor fails if tzinfo is specified
Feb 12, 2020
The constructor for
pd.Timestamp
has both atz=
andtzinfo=
argument, presumably becausepd.Timestamp
is trying to both support thedatetime.datetime
interface and its own constructor. There is evidently logic in the constructor to prevent bothtz
andtzinfo
being specified, but it seems something has gone wrong, because constructing an awarepd.Timestamp
by components and includingtzinfo
always raises an exception, see:This raises the following exception:
Despite the fact that only
tzinfo
was specified. This seems to only occur when you are using the "per-component" specification, as passing adatetime
or epoch time as the first component allows you to specify the time zone usingtzinfo
:The text was updated successfully, but these errors were encountered: