8000 fix for BUG: grouping with tz-aware: Values falls after last bin by ahcub · Pull Request #24973 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

fix for BUG: grouping with tz-aware: Values falls after last bin #24973

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

Merged
merged 16 commits into from
Jan 29, 2019
Merged
Prev Previous commit
Next Next commit
move tests
  • Loading branch information
ahcub committed Jan 28, 2019
commit 5c07d25f6ffb0d766b9e5f21c5f8977a2898b0f9
14 changes: 0 additions & 14 deletions pandas/tests/groupby/test_timegrouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,17 +650,3 @@ def test_scalar_call_versus_list_call(self):
expected = grouped.count()

assert_frame_equal(result, expected)

def test_groupby_with_dst_time_change(self):
# GH 24972
index = pd.DatetimeIndex([1478064900001000000, 1480037118776792000],
tz='UTC').tz_convert('America/Chicago')

df = pd.DataFrame([1, 2], index=index)
result = df.groupby(pd.Grouper(freq='1d')).last()
expected_index_values = pd.date_range('2016-11-02', '2016-11-24',
freq='d', tz='America/Chicago')

index = pd.DatetimeIndex(expected_index_values)
expected = pd.DataFrame([1.0] + ([np.nan] * 21) + [2.0], index=index)
assert_frame_equal(result, expected)
15 changes: 15 additions & 0 deletions pandas/tests/resample/test_datetime_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,21 @@ def test_resample_across_dst():
assert_frame_equal(result, expected)


def test_groupby_with_dst_time_change():
# GH 24972
index = pd.DatetimeIndex([1478064900001000000, 1480037118776792000],
tz='UTC').tz_convert('America/Chicago')

df = pd.DataFrame([1, 2], index=index)
result = df.groupby(pd.Grouper(freq='1d')).last()
expected_index_values = pd.date_range('2016-11-02', '2016-11-24',
freq='d', tz='America/Chicago')

index = pd.DatetimeIndex(expected_index_values)
expected = pd.DataFrame([1.0] + ([np.nan] * 21) + [2.0], index=index)
assert_frame_equal(result, expected)


def test_resample_dst_anchor():
# 5172
dti = DatetimeIndex([datetime(2012, 11, 4, 23)], tz='US/Eastern')
Expand Down
0