Skip to content
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

DOC: to_datetime not type-stable on mixed timezones (possible bug) #40808

Closed
mkovarik337 opened this issue Apr 6, 2021 · 2 comments · Fixed by #41049
Closed

DOC: to_datetime not type-stable on mixed timezones (possible bug) #40808

mkovarik337 opened this issue Apr 6, 2021 · 2 comments · Fixed by #41049
Labels
Datetime Datetime data dtype Docs Timezones Timezone data dtype
Milestone

Comments

@mkovarik337
Copy link

Note: This behaviour might be a bug. I'm assuming its an undocumented feature.

Location of the documentation

pandas.to_datetime.html

Documentation problem

to_datetime outputs different types depending on if the timezones are mixed or not (assuming utc=True not passed in).

MIXED = ["2018-10-26 12:00 -0500", "2018-10-26 12:00 -0400"]
UNMIXED = ["2018-10-26 12:00 -0500", "2018-10-26 12:00 -0500"]

print(pandas.to_datetime(MIXED).dtype)   # ==> object
print(pandas.to_datetime(UNMIXED).dtype) # ==> datetime64[ns, pytz.FixedOffset(-300)]

Suggested fix for documentation

Specify aforementioned behaviour in documentation (in the returns section). Or, if not intentional feature, update the API to be type-stable.

@mkovarik337 mkovarik337 added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 6, 2021
@mroeschke
Copy link
Member

We do have tests asserting this object dtype (test_construction_index_with_mixed_timezones), but could use more documentation in to_datetime regarding this behavior

@mroeschke mroeschke added Datetime Datetime data dtype Timezones Timezone data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 6, 2021
@chinmayrane
Copy link
Contributor

take

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

Successfully merging a pull request may close this issue.

4 participants