File tree 1 file changed +6
-14
lines changed
1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -1979,27 +1979,19 @@ def _ensure_listlike_indexer(self, key):
1979
1979
"""
1980
1980
column_axis = 1
1981
1981
1982
- # check if self.obj is at least 2-dimensional
1983
- if len ( self .obj . shape ) <= column_axis :
1982
+ # column only exists in 2-dimensional DataFrame
1983
+ if self .ndim != 2 :
1984
1984
return
1985
1985
1986
1986
if isinstance (key , tuple ):
1987
- # key is a _LocIndexer key
1988
-
1989
- if not (
1990
- # key indexes multiple columns
1991
- is_list_like_indexer (key [column_axis ])
1992
- and not com .is_bool_indexer (key [column_axis ])
1993
- ):
1994
- return
1995
-
1996
- # set key to the column part of key which is a list-like of column
1997
- # labels
1987
+ # key may be a tuple if key is a _LocIndexer key
1988
+ # in that case, set key to the column part of key
1998
1989
key = key [column_axis ]
1999
1990
2000
1991
if (
2001
1992
not isinstance (self .obj ._get_axis (column_axis ), ABCMultiIndex )
2002
- and is_list_like (key )
1993
+ and is_list_like_indexer (key )
1994
+ and not com .is_bool_indexer (key )
2003
1995
and all (is_hashable (k ) for k in key )
2004
1996
):
2005
1997
for k in key :
You can’t perform that action at this time.
0 commit comments