Skip to content

pd.Timestamp.utcfromtimestamp should return tzaware #22451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbrockmendel opened this issue Aug 21, 2018 · 2 comments · Fixed by #45083
Closed

pd.Timestamp.utcfromtimestamp should return tzaware #22451

jbrockmendel opened this issue Aug 21, 2018 · 2 comments · Fixed by #45083
Labels
Enhancement Timezones Timezone data dtype
Milestone

Comments

@jbrockmendel
Copy link
Member

ATM pd.Timestamp.utcnow() returns a UTC-localized Timestamp object, but pd.Timestamp.utcfromtimestamp() does not. As a result, the following round-trip fails:

unow = pd.Timestamp.utcnow()
result = pd.Timestamp.utcfromtimestamp(unow.timestamp())
assert unow == result  # <-- TypeError because unow is tzaware and result is tznaive

Changing this would mean breaking with the stdlib, but our utcnow already breaks with the stdlib (see also #22450)

@mroeschke
Copy link
Member

+1 I think breaking from the stdlib is fine since we offset rich support for timezones and we do not advertise Timestamp as a direct replacement for datetime.datetime

@mroeschke mroeschke added API Design Timezones Timezone data dtype labels Aug 22, 2018
@jbrockmendel
Copy link
Member Author

BTW, there is now a thread on the datetime stdlib SIG mailing list (https://mail.python.org/archives/list/[email protected]/thread/PT4JWJLYBE5R2QASVBPZLHH37ULJQR43/) about changing datetime.utcnow and datetime.utcfromtimestamp behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants