Skip to content

BUG: Regression in loc __setitem__ with split_path True and all false indexr #40885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
phofl opened this issue Apr 11, 2021 · 1 comment · Fixed by #40999
Closed

BUG: Regression in loc __setitem__ with split_path True and all false indexr #40885

phofl opened this issue Apr 11, 2021 · 1 comment · Fixed by #40999
Labels
Blocker Blocking issue or pull request for an upcoming release Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@phofl
Copy link
Member

phofl commented Apr 11, 2021

We have an ugly regression on master

Code Sample, a copy-pastable example

df = DataFrame({"a": [1, 2], "b": [3, 4], "c": "a"})

indexer = Series([False, False], name="c")
rhs = DataFrame({"b": [5, 6]}, index=[0, 1])
df.loc[indexer, ["b"]] = rhs

We need more than one block to reproduce

Problem description

This returns

   a  b  c
0  1  5  a
1  2  6  a

which is obviously wrong.

Expected Output

   a  b  c
0  1  3  a
1  2  4  a

I think this was introduced with 8022743 cc @jbrockmendel

_align_series previously returns the value, if the indexer is all False, which is not caught here anymore, since we run into

        elif is_array_like(value) and is_exact_shape_match(ser, value):
            ser = value

INSTALLED VERSIONS

commit : 895f0b4
python : 3.8.6.final.0
python-bits : 64
OS : Linux
OS-release : 5.8.0-48-generic
Version : #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.3.0.dev0+1287.g895f0b4022
numpy : 1.20.0
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.3
setuptools : 49.6.0.post20210108
Cython : 0.29.21
pytest : 6.2.1
hypothesis : 6.0.2
sphinx : 3.4.3
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.6.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.8.5
fastparquet : 0.5.0
gcsfs : 0.7.1
matplotlib : 3.3.3
numexpr : 2.7.2
odfpy : None
openpyxl : 3.0.6
pandas_gbq : None
pyarrow : 1.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.6.0
sqlalchemy : 1.3.22
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.2
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.52.0
None

@phofl phofl added Bug Needs Triage Issue that has not been reviewed by a pandas team member Blocker Blocking issue or pull request for an upcoming release Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 11, 2021
@phofl phofl added this to the 1.3 milestone Apr 11, 2021
@jbrockmendel
Copy link
Member

i guess is_exact_shape_match is implicitly assuming that it has a sequence-of-ints indexer and needs to either check for boolean mask or ensure that is handled earlier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker Blocking issue or pull request for an upcoming release Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants