Skip to content

BUG: loc.setitem casting dtype to float with all false Indexer and rhs is an empty list #45981

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
3 tasks done
phofl opened this issue Feb 14, 2022 · 3 comments · Fixed by #51193
Closed
3 tasks done
Assignees
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@phofl
Copy link
Member

phofl commented Feb 14, 2022

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

df = pd.DataFrame({"a": [1, 2]})

df.loc[[False, False]] = []

This also happens for multi block DataFrames

df = pd.DataFrame({"a": [1, 2], "b": "a"})

df.loc[[False, False], "a"] = []

Issue Description

   a
0  1.0
1  2.0

Expected Behavior

   a
0  1
1  2

Installed Versions

INSTALLED VERSIONS

commit : 68f763e
python : 3.8.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.13.0-28-generic
Version : #31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.5.0.dev0+348.g68f763e753
numpy : 1.22.0
pytz : 2021.1
dateutil : 2.8.2
pip : 21.3.1
setuptools : 59.8.0
Cython : 0.29.24
pytest : 6.2.5
hypothesis : 6.23.1
sphinx : 4.2.0
blosc : None
feather : None
xlsxwriter : 3.0.1
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.28.0
pandas_datareader: None
bs4 : 4.10.0
bottleneck : 1.3.2
fastparquet : 0.7.1
fsspec : 2021.11.0
gcsfs : 2021.05.0
matplotlib : 3.4.3
numba : 0.53.1
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 3.0.0
pyreadstat : 1.1.2
pyxlsb : None
s3fs : 2021.11.0
scipy : 1.7.2
sqlalchemy : 1.4.25
tables : 3.6.1
tabulate : 0.8.9
xarray : 0.18.0
xlrd : 2.0.1
xlwt : 1.3.0
zstandard : None
None

Process finished with exit code 0

@phofl phofl added Bug Needs Triage Issue that has not been reviewed by a pandas team member Indexing Related to indexing on series/frames, not to indexes themselves labels Feb 14, 2022
@simonjayhawkins simonjayhawkins removed the Needs Triage Issue that has not been reviewed by a pandas team member label Feb 14, 2022
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Feb 14, 2022
@MichaelTiemannOSC
Copy link
Contributor

The unbearable floatness of nullability (with apologies to The Unbearable Lightness of Being).

@andjhall
Copy link
Contributor

take

@simonjayhawkins
Copy link
Member

simonjayhawkins commented Jun 25, 2022

the same assignment a second time raises (on main)

df = pd.DataFrame({"a": [1, 2]})

df.loc[[False, False]] = []
df.loc[[False, False]] = []
# ValueError: shape mismatch: value array of shape (0,) could not be broadcast to indexing result of shape (0,1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants