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

BUG: DatetimeIndex.astype matches Series.dtype with datetime tz dtype #33409

Closed

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke added Bug Timezones Timezone data dtype labels Apr 8, 2020
@mroeschke mroeschke added this to the 1.1 milestone Apr 8, 2020
@@ -586,7 +586,8 @@ def astype(self, dtype, copy=True):
# GH#18951: datetime64_ns dtype but not equal means different tz
new_tz = getattr(dtype, "tz", None)
if getattr(self.dtype, "tz", None) is None:
return self.tz_localize(new_tz)
# GH 33401: Match the behavior of Series.astype
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it obvious that Series is the better behavior? it might be that the only unambiguous thing to do is raise and require the user to be explicit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. The implicit UTC localization isn't my favorite behavior.

With that in mind, should we deprecate the Series.astype(tz_dtype) UTC localization behavior instead?

@mroeschke
Copy link
Member Author

As @jbrockmendel mentioned, this may not be the idea behavior in the first place. Going to close so we can discuss further in the issue

@mroeschke mroeschke closed this Apr 9, 2020
@mroeschke mroeschke deleted the datetimeindex_astype_tz branch April 9, 2020 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Index.astype does not localize to UTC first like Series.astype with datetime64[ns, tz] dtypes
2 participants