-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
BUG: indexing with loc and iloc with list-likes and new dtypes do not change from object dtype #20635
Comments
the first example should be int. this is a bug. if you'd like to have a look would be great. |
In my testing, I have been gettting this bug when the starting dataframe is all strings. `import pandas as pd print('DF2 as Data Frame') print('DF as Data Frame') print('DF3 as Data Frame') print('DF4 as Data Frame') results
The issue does not occur when they are all either ints, floats or a combination of ints and floats. This occurs because strings are considered objects by python and the int and floats are considered as “numeric” objects. So what is happening is that when we are trying to convert the strings to any of the numeric object type it creates a temp and then when we try the conversion again it is converting the strings to numeric types. Could be related with this issue #11617 |
similar to #24269 |
When I try to update multiple object columns with loc/iloc, the values in the columns change but object dtype is preserved. This is not the case for numeric dtypes.
Shouldn't the columns in the first example have integer dtypes? I found this issue but it seems it is specific to extension arrays. Also, if I try it with a single column like the one in the linked issue, the dtype changes:
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.10.0-42-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.22.0
pytest: 3.4.1
pip: 9.0.2
setuptools: 38.5.1
Cython: 0.27.3
numpy: 1.14.2
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: 1.7.1
patsy: 0.5.0
dateutil: 2.7.0
pytz: 2018.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: 2.5.0
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.4
pymysql: None
psycopg2: 2.7.4 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: