-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Bug: loc assignment results in wrong dtype #31340
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
Comments
Thanks for the report. I couldn't reproduce this on master:
|
Will close this then, as it looks like it's been fixed already |
@MarcoGorelli i think this is worth a validation test (unless we already have something that is pretty close in the tests) |
Admittedly I hadn't checked for that, sorry - have reopened for now, will take a look later |
Reproducible on 0.25.0 (fixed on master). I will try to come up with a test if one doesn't exist. |
Let's see output of this code snippet
Problem description
In this code we expect columns
'a', 'b', 'c'
will have typesfloat32
. But in fact the result is:Bug occurs when the value in column is close to integer. In other words, for
df = pd.DataFrame({'id': ['A'], 'a': [1.2], 'b': [1.0], 'c': [-2.5]})
behavior will be the same. However, if df has 2 rows or more the result is right:Output of
pd.show_versions()
pandas : 0.25.3
numpy : 1.17.4
pytz : 2018.4
dateutil : 2.7.5
pip : 19.2.3
setuptools : 41.6.0
Cython : 0.28.2
pytest : 3.5.1
hypothesis : None
sphinx : 1.7.4
blosc : None
feather : None
xlsxwriter : 1.0.4
lxml.etree : 4.2.1
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.7.5 (dt dec pq3 ext lo64)
jinja2 : 2.10
IPython : 6.4.0
pandas_datareader: None
bs4 : 4.6.3
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.2.1
matplotlib : 3.0.1
numexpr : 2.6.5
odfpy : None
openpyxl : 2.5.3
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.1.0
sqlalchemy : 1.2.14
tables : 3.4.3
xarray : None
xlrd : 1.1.0
xlwt : 1.3.0
xlsxwriter : 1.0.4
The text was updated successfully, but these errors were encountered: