Description
Code Sample, a copy-pastable example if possible
>>> import pandas as pd
>>> df = pd.DataFrame({"a": [3, 4], "b": [5, 6]}).astype({"a": "int64", "b": "Int64"})
>>> df["a"]
0 3
1 4
Name: a, dtype: int64
>>> df["b"]
0 5
1 6
Name: b, dtype: Int64
>>> mask = pd.Series(False, index=df.index)
>>> df.loc[mask, "a"] = df["a"]
>>> df.loc[mask, "b"] = df["b"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python3.6/site-packages/pandas/core/indexing.py", line 190, in __setitem__
self._setitem_with_indexer(indexer, value)
File "/lib/python3.6/site-packages/pandas/core/indexing.py", line 605, in _setitem_with_indexer
setter(labels[0], value)
File "/lib/python3.6/site-packages/pandas/core/indexing.py", line 539, in setter
s._data = s._data.setitem(indexer=pi, value=v)
File "/lib/python3.6/site-packages/pandas/core/internals/managers.py", line 510, in setitem
return self.apply('setitem', **kwargs)
File "/lib/python3.6/site-packages/pandas/core/internals/managers.py", line 395, in apply
applied = getattr(b, f)(**kwargs)
File "/lib/python3.6/site-packages/pandas/core/internals/blocks.py", line 1751, in setitem
check_setitem_lengths(indexer, value, self.values)
File "/lib/python3.6/site-packages/pandas/core/indexing.py", line 2534, in check_setitem_lengths
raise ValueError("cannot set using a list-like indexer "
ValueError: cannot set using a list-like indexer with a different length than the value
Problem description
I would not expect the type of the Series to affect the masking behavior.
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit: None
python: 3.6.8.final.0
python-bits: 64
OS: Linux
OS-release: 4.19.43
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.2
pytest: 4.2.1
pip: None
setuptools: 40.8.0
Cython: None
numpy: 1.16.4
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: None
openpyxl: 2.6.0
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: None
lxml.etree: 4.3.1
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.2.14
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None