Skip to content

BUG: Series.combine_first with mixed timezones #26379

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
wants to merge 2 commits into from

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype labels May 14, 2019
@mroeschke mroeschke added this to the 0.25.0 milestone May 14, 2019
@codecov
Copy link

codecov bot commented May 14, 2019

Codecov Report

Merging #26379 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26379      +/-   ##
==========================================
- Coverage   91.68%   91.67%   -0.01%     
==========================================
  Files         174      174              
  Lines       50704    50706       +2     
==========================================
- Hits        46489    46487       -2     
- Misses       4215     4219       +4
Flag Coverage Δ
#multiple 90.18% <100%> (ø) ⬆️
#single 41.17% <0%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 97.03% <100%> (+0.17%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97.01% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.6% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2123a96...daa528c. Read the comment docs.

@codecov
Copy link

codecov bot commented May 14, 2019

Codecov Report

Merging #26379 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26379      +/-   ##
==========================================
- Coverage   91.68%   91.67%   -0.01%     
==========================================
  Files         174      174              
  Lines       50704    50706       +2     
==========================================
- Hits        46489    46487       -2     
- Misses       4215     4219       +4
Flag Coverage Δ
#multiple 90.18% <100%> (ø) ⬆️
#single 41.17% <0%> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/core/indexes/datetimes.py 97.03% <100%> (+0.17%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97.01% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.6% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2123a96...eeeda48. Read the comment docs.

@@ -489,6 +489,9 @@ def union(self, other, sort=None):
other = DatetimeIndex(other)
except TypeError:
pass
except ValueError:
# GH 26283: Convert indexes with mixed tz to UTC
other = tools.to_datetime(other, utc=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not correct; rather you should call the super.union() as these must be combined as Index rather than DTI

Copy link
Member Author

Choose a reason for hiding this comment

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

So super().union actually returns the same result because these evaluate as equal:

>>> Timestamp('2019-05-01 00:00:00', tz='UTC') == Timestamp('2019-05-01 01:00:00', tz='Europe/London')
True

While an Index with all Timestamps feels a little more correct, a DTI with UTC timestamps is technically correct too since the above is True. (And less code to handle this special casing is a nice plus)

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree, we are striving never to coerce to UTC unless its explicit, this should stay as object dtyped.

@mroeschke
Copy link
Member Author

This fix is a littler tricker than expected. Closing for now.

@mroeschke mroeschke closed this May 19, 2019
@mroeschke mroeschke deleted the concat_first_mixed_tz branch July 22, 2019 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series.combine_first raises ValueError on mixed-timezone datetime-index
3 participants