Skip to content

Commit

Permalink
9236: test for the DataFrame.groupby with MultiIndex having pd.NaT (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam Rana authored and alimcmaster1 committed Jun 3, 2019
1 parent 939428a commit e96f1a2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1698,3 +1698,19 @@ def test_groupby_agg_ohlc_non_first():
result = df.groupby(pd.Grouper(freq='D')).agg(['sum', 'ohlc'])

tm.assert_frame_equal(result, expected)


def test_groupby_multiindex_nat():
# GH 9236
values = [
(pd.NaT, 'a'),
(datetime(2012, 1, 2), 'a'),
(datetime(2012, 1, 2), 'b'),
(datetime(2012, 1, 3), 'a')
]
mi = pd.MultiIndex.from_tuples(values, names=['date', None])
ser = pd.Series([3, 2, 2.5, 4], index=mi)

result = ser.groupby(level=1).mean()
expected = pd.Series([3., 2.5], index=["a", "b"])
assert_series_equal(result, expected)

0 comments on commit e96f1a2

Please sign in to comment.