File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -202,11 +202,13 @@ def _get_setitem_indexer(self, key):
202
202
def __setitem__ (self , key , value ):
203
203
if isinstance (key , tuple ):
204
204
key = tuple (com .apply_if_callable (x , self .obj ) for x in key )
205
+ # if `key` is an index to multiple columns by name, add each column
206
+ # if it does not already exist
205
207
if (
206
- self .name == "loc"
207
- and len (key ) > 1
208
- and is_list_like_indexer (key [1 ])
209
- and not isinstance (key [ 1 ], tuple )
208
+ self .name == "loc" # column is indexed by name
209
+ and len (key ) >= 2 # key is at least 2-dimensional
210
+ and is_list_like_indexer (key [1 ]) # key indexes multiple columns
211
+ and not isinstance (self . obj . _get_axis ( 1 ), ABCMultiIndex )
210
212
and not com .is_bool_indexer (key [1 ])
211
213
and all (is_hashable (k ) for k in key [1 ])
212
214
):
You can’t perform that action at this time.
0 commit comments