From 30c1c70d5e1e266db7e8a125c1ac4d3cd89d6da8 Mon Sep 17 00:00:00 2001 From: Matt Roeschke Date: Sat, 17 Dec 2016 23:05:40 -0800 Subject: [PATCH] TST: Groupby/transform with grouped NaN (#9941) --- pandas/tests/groupby/test_groupby.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index 97e1f7dc94866..f8d9d73590a60 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -1374,6 +1374,15 @@ def test_groupby_transform_with_int(self): expected = DataFrame(dict(B=1, C=[2, 3, 4, 10, 5, -1])) assert_frame_equal(result, expected) + def test_groupby_transform_with_nan_group(self): + # GH 9941 + df = pd.DataFrame({'a': range(10), + 'b': [1, 1, 2, 3, np.nan, 4, 4, 5, 5, 5]}) + result = df.groupby(df.b)['a'].transform(max) + expected = pd.Series([1., 1., 2., 3., np.nan, 6., 6., 9., 9., 9.], + name='a') + assert_series_equal(result, expected) + def test_indices_concatenation_order(self): # GH 2808