Closed
Description
Code Sample, a copy-pastable example if possible
import datetime as dt
import pandas as pd
t = dt.datetime.now()
ts1 = t.timestamp()
ts2 = pd.Timestamp(t).timestamp()
print((ts1 - ts2) / 3600)
Problem description
Pandas and Datetime evidently have different defaults when handling time objects for which tzinfo=None
. This changed somewhere in between pandas 0.19 and 0.23 (upgrading broke a bunch of my tests). I think keeping consistency between these two libraries would remove some of the confusion in the bizarrely complicated area that is python time-handling.
In the example, the two timestamp floats should match. Currently, my understanding is the datetime library defaults to the current timezone whereas Pandas assumes GMT. There isn't information in the Pandas API documentation regarding how Timestamp.timestamp()
handles naive Timestamps (link).