-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Merge timezone aware data with DST #22825
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
Changes from 5 commits
ce784e0
52602b9
cff2bca
cc5e9cf
da257a3
c9cc43a
9eca40e
254af4e
26b0600
f5c3083
e4491d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -601,6 +601,30 @@ def test_merge_on_datetime64tz(self): | |
assert result['value_x'].dtype == 'datetime64[ns, US/Eastern]' | ||
assert result['value_y'].dtype == 'datetime64[ns, US/Eastern]' | ||
|
||
def test_merge_datetime64tz_with_dst_transition(self): | ||
# GH 18885 | ||
df1 = pd.DataFrame(pd.date_range( | ||
'2017-10-29 01:00', periods=4, freq='H', tz='Europe/Madrid'), | ||
columns=['date']) | ||
df1['value'] = 1 | ||
df2 = pd.DataFrame([ | ||
pd.to_datetime('2017-10-29 03:00:00'), | ||
pd.to_datetime('2017-10-29 04:00:00'), | ||
pd.to_datetime('2017-10-29 05:00:00') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you create this one as well with date_range to shorten it a bit? (and if not, I think it is more typical to pass a list of strings to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can maybe also directly include the 'value' column in the constructor |
||
], | ||
columns=['date']) | ||
df2['date'] = df2['date'].dt.tz_localize('UTC').dt.tz_convert( | ||
'Europe/Madrid') | ||
df2['value'] = 2 | ||
result = pd.merge(df1, df2, how='outer', on='date') | ||
expected = pd.DataFrame({ | ||
'date': pd.date_range( | ||
'2017-10-29 01:00', periods=7, freq='H', tz='Europe/Madrid'), | ||
'value_x': [1] * 4 + [np.nan] * 3, | ||
'value_y': [np.nan] * 4 + [2] * 3 | ||
}) | ||
assert_frame_equal(result, expected) | ||
|
||
def test_merge_non_unique_period_index(self): | ||
# GH #16871 | ||
index = pd.period_range('2016-01-01', periods=16, freq='M') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was bizarrely structured above. It was given the wrong arguments for everything to pass before it hit the xfail...
Good news is that one of the cases is passing, so I am splitting the tz-aware and tz-naive case and properly xfailing the tz-aware case (which was already failing on master and is orthogonal to this change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there an issue for this case? if not can you create one and reference it here