9
9
10
10
from pandas .core .series import Series
11
11
12
- from pandas .util .testing import (assert_frame_equal , assert_series_equal
13
- )
12
+ from pandas .util .testing import (assert_frame_equal , assert_series_equal ,
13
+ assert_numpy_array_equal )
14
14
15
15
from pandas .compat import (lmap )
16
16
@@ -48,8 +48,9 @@ def setUp(self):
48
48
'D' : np .array (
49
49
np .random .randn (8 ), dtype = 'float32' )})
50
50
51
- index = MultiIndex (levels = [['foo' , 'bar' , 'baz' , 'qux' ], ['one' , 'two' ,
52
- 'three' ]],
51
+ index = MultiIndex (levels = [pd .CategoricalIndex (
52
+ ['foo' , 'bar' , 'baz' , 'qux' ]),
53
+ ['one' , 'two' , 'three' ]],
53
54
labels = [[0 , 0 , 0 , 1 , 1 , 2 , 2 , 3 , 3 , 3 ],
54
55
[0 , 1 , 2 , 0 , 1 , 1 , 2 , 0 , 1 , 2 ]],
55
56
names = ['first' , 'second' ])
@@ -67,6 +68,12 @@ def setUp(self):
67
68
'E' : np .random .randn (11 ),
68
69
'F' : np .random .randn (11 )})
69
70
71
+ def test_level_groupby_get_group (self ):
72
+ # gh15155
73
+ testGroupBy = self .mframe .groupby (level = ["first" ])
74
+ assert_numpy_array_equal (testGroupBy .get_group ("foo" ).values ,
75
+ self .mframe .loc ["foo" ].values )
76
+
70
77
def test_apply_use_categorical_name (self ):
71
78
from pandas import qcut
72
79
cats = qcut (self .df .C , 4 )
0 commit comments