BUG: DataFrame.iloc[idx, column] = array
sets incorrect values for 1.5.0
#48835
Labels
DataFrame.iloc[idx, column] = array
sets incorrect values for 1.5.0
#48835
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
You should be able to (and can in all prior
pandas
versions) set the values of aDataFrame
with a boolean index array and anumpy
array of values with the proper size, like in the included example:However, doing this results in the data from
rhs_values
being apparently randomly inserted into column 'a'. All of the values from the array are inserted into column 'a', but they are not set in the same order as they appear inrhs_values
, even though the indexidx
is in the same order asdf.index
and allTrue
.The output of the included example is below. After attempting to set with
.loc[idx, 'a']
, the values indf
are not correct. After setting with['a']
, the are correct.Expected Behavior
The expected behavior is for
df.loc[idx, 'a'] = values
to set the contents of column 'a' to the givenvalues
in the correct order ifidx
is a boolean array in the same order asdf.index
.The included example's output should be:
Installed Versions
The text was updated successfully, but these errors were encountered: