@@ -124,6 +124,15 @@ def test_getitem_single_column(self):
124
124
125
125
tm .assert_series_equal (result , expected )
126
126
127
+ def test_indices_grouped_by_tuple_with_lambda (self ):
128
+ df = pd .DataFrame ({'Tuples' : ((x , y )
129
+ for x in [0 , 1 ]
130
+ for y in np .random .randint (3 , 5 , 5 ))})
131
+ gb = df .groupby ('Tuples' )
132
+ gb_lambda = df .groupby (lambda x : df .iloc [x , 0 ])
133
+ expected = gb .indices
134
+ result = gb_lambda .indices
135
+ tm .assert_dict_equal (result , expected )
127
136
128
137
# grouping
129
138
# --------------------------------
@@ -775,6 +784,16 @@ def test_get_group_grouped_by_tuple(self):
775
784
expected = DataFrame ({"ids" : [(dt [0 ],), (dt [0 ],)]}, index = [0 , 2 ])
776
785
tm .assert_frame_equal (result , expected )
777
786
787
+ def test_get_group_grouped_by_tuple_with_lambda (self ):
788
+ df = pd .DataFrame ({'Tuples' : ((x , y )
789
+ for x in [0 , 1 ]
790
+ for y in np .random .randint (3 , 5 , 5 ))})
791
+ gb = df .groupby ('Tuples' )
792
+ gb_lambda = df .groupby (lambda x : df .iloc [x , 0 ])
793
+ expected = gb .get_group (list (gb .groups .keys ())[0 ])
794
+ result = gb_lambda .get_group (list (gb_lambda .groups .keys ())[0 ])
795
+ tm .assert_frame_equal (result , expected )
796
+
778
797
def test_groupby_with_empty (self ):
779
798
index = pd .DatetimeIndex (())
780
799
data = ()
0 commit comments