@@ -520,21 +520,21 @@ def _get_grouper(obj, key=None, axis=0, level=None, sort=True,
520
520
any_arraylike = any (isinstance (g , (list , tuple , Series , Index , np .ndarray ))
521
521
for g in keys )
522
522
523
- try :
524
- if isinstance (obj , DataFrame ):
525
- all_in_columns_index = all (g in obj .columns or g in obj .index .names
526
- for g in keys )
527
- elif isinstance (obj , Series ):
528
- all_in_columns_index = all (g in obj .index .names for g in keys )
529
- else :
523
+ if (not any_callable and not any_arraylike and not any_groupers and
524
+ match_axis_length and level is None ):
525
+ try :
526
+ if isinstance (obj , DataFrame ):
527
+ all_in_columns_index = all (g in obj .columns or g in
528
+ obj .index .names for g in keys )
529
+ elif isinstance (obj , Series ):
530
+ all_in_columns_index = all (g in obj .index .names for g in keys )
531
+ else :
532
+ all_in_columns_index = False
533
+ except Exception :
530
534
all_in_columns_index = False
531
- except Exception :
532
- all_in_columns_index = False
533
535
534
- if (not any_callable and not all_in_columns_index and
535
- not any_arraylike and not any_groupers and
536
- match_axis_length and level is None ):
537
- keys = [com .asarray_tuplesafe (keys )]
536
+ if not all_in_columns_index :
537
+ keys = [com .asarray_tuplesafe (keys )]
538
538
539
539
if isinstance (level , (tuple , list )):
540
540
if key is None :
0 commit comments