Skip to content

Commit b7403bf

Browse files
committed
TST: Groupby.groups of datetimeindex (#11442)
1 parent f79bc7a commit b7403bf

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/groupby/test_groupby.py

+11
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,17 @@ def test_groupby_groups_datetimeindex(self):
39333933
groups = grouped.groups
39343934
tm.assertIsInstance(list(groups.keys())[0], datetime)
39353935

3936+
# GH 11442
3937+
index = pd.date_range('2015/01/01', periods=5, name='date')
3938+
df = pd.DataFrame({'A': [5, 6, 7, 8, 9],
3939+
'B': [1, 2, 3, 4, 5]}, index=index)
3940+
result = df.groupby(level='date').groups
3941+
dates = ['2015-01-05', '2015-01-04', '2015-01-03',
3942+
'2015-01-02', '2015-01-01']
3943+
expected = {pd.Timestamp(date): pd.DatetimeIndex([date], name='date')
3944+
for date in dates}
3945+
tm.assert_dict_equal(result, expected)
3946+
39363947
def test_groupby_groups_datetimeindex_tz(self):
39373948
# GH 3950
39383949
dates = ['2011-07-19 07:00:00', '2011-07-19 08:00:00',

0 commit comments

Comments
 (0)