@@ -3063,6 +3063,25 @@ def test_groupby_non_arithmetic_agg_types(self):
3063
3063
t = getattr (grpd , method )(* data ['args' ])
3064
3064
assert_frame_equal (t , df_out )
3065
3065
3066
+ def test_groupby_multiindex_tuple (self ):
3067
+ # GH 17979
3068
+ df = pd .DataFrame ([[1 , 2 , 3 , 4 ], [3 , 4 , 5 , 6 ], [1 , 4 , 2 , 3 ]],
3069
+ columns = pd .MultiIndex .from_arrays (
3070
+ [['a' , 'b' , 'b' , 'c' ],
3071
+ [1 , 1 , 2 , 2 ]]))
3072
+ expected = df .groupby ([('b' , 1 )]).groups
3073
+ result = df .groupby (('b' , 1 )).groups
3074
+ tm .assert_dict_equal (expected , result )
3075
+
3076
+ df2 = pd .DataFrame ([[1 , 2 , 3 , 4 ], [3 , 4 , 5 , 6 ], [1 , 4 , 2 , 3 ]],
3077
+ columns = pd .MultiIndex .from_arrays (
3078
+ [['a' , 'b' , 'b' , 'c' ],
3079
+ ['d' , 'd' , 'e' , 'e' ]]))
3080
+ df2 .groupby ([('b' , 'd' )]).groups
3081
+ expected = df .groupby ([('b' , 'd' )]).groups
3082
+ result = df .groupby (('b' , 'd' )).groups
3083
+ tm .assert_dict_equal (expected , result )
3084
+
3066
3085
def test_groupby_non_arithmetic_agg_intlike_precision (self ):
3067
3086
# GH9311, GH6620
3068
3087
c = 24650000000000000
0 commit comments