Skip to content

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

Closed
@phofl

Description

@phofl

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BlockerBlocking issue or pull request for an upcoming releaseIndexingRelated to indexing on series/frames, not to indexes themselvesRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions