BUG: errors with .loc[(slice(...), ), ]
when modifying a subset of rows in a pandas dataframe/series in 1.1.4
#37711
Labels
Bug
Indexing
Related to indexing on series/frames, not to indexes themselves
Regression
Functionality that used to work in a prior pandas version
Milestone
I often use
.loc[(slice(...),),]
for selection and modifying when dealing with both series and dataframe: seeadvanced-indexing-with-hierarchical-index
Every thinkg is OK in
0.25.4
, but in1.1.4
(also1.0.3
and1.1.3
), only selection is valid and modifying will raise errors:but when I try to modify a subset of rows using
.loc[(slice(...),),]
and
Note that “partial” indexing
.loc[slice(...)]
is still valid in ``1.1.4`:Of course,
.loc[('a', )]
is valid for series and.loc[('a', ), : ]
is vaild for dataframe, but I have to use different codes for series and dataframe.Update on 20201113:
s.loc[('a')] = 0
,s.loc[('a', )] = 0
ands.loc[('a'), ] = 0
are vaild, buts.loc[('a', ), ] = 0
will raise similar AssertionError like above.df.loc[('a')] = 0
,df.loc[('a'), :] = 0
anddf.loc[('a',), :] = 0
are vaild, butdf.loc[('a', )] = 0
,df.loc[('a'), ] = 0
anddf.loc[('a', ), ] = 0
will raise similar IndexError like above.The text was updated successfully, but these errors were encountered: