BUG: Cannot assign values to DataFrame using mask after previous multi-column __setitem__
value assignment
#45593
Labels
Bug
Error Reporting
Incorrect or improved errors from pandas
Indexing
Related to indexing on series/frames, not to indexes themselves
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
It's impossible to assign values to DataFrame using a DataFrame mask if the source DataFrame's values were assigned in a multi-column fashion by using
__setitem__
.This seems to be a regression in pandas 1.4.0rc0 as the code is running fine under 1.3.5 or possibly an udocumented change - unless I missed this being mentioned in the changelog.
Comparatively the following code works:
Moreover the following assignment variants don't cause any problems:
I apologize if this issue is known under different keywords.
Traceback
Expected Behavior
DataFrame should have it's values assigned based on the mask. An REPL example follows:
Installed Versions
pandas : 1.4.0
numpy : 1.20.2
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 47.3.1
Cython : None
pytest : 6.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.22.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.3.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 3.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.5.3
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : 1.2.0
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: