-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Assigned conversion via loc to Int64 fails under peculiar conditions #31861
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
I'm happy to report that this works when using # works
test = pd.DataFrame({'a': ['test'], 'b': [pd.NA]})
test.loc[:, 'b'] = test.loc[:, 'b'].astype('Int64') |
This works fine in pandas 1.1.1. A PR that adds a test for this would be welcome. |
take |
@TAJD, are you still working on the test? I would like to contribute if otherwise. |
Please contribute! I'm no longer working on this. |
Take |
So far I have added a test for functionality similar to the one provided in the issue. Basically, test astype via loc on np.nan on |
Code Sample, a copy-pastable example if possible
Problem description
Assignment of
.astype('Int64')
sometimes fails withAttributeError: 'IntegerArray' object has no attribute 'size'
.Initially, I thought this was a regression from #25584, but it only manifests under very specific conditions:
df.loc[:, colname]
- without assignment, or with assignment todf[colname]
, things work.Expected Output
test.loc[:, 'b'] = test.loc[:, 'b'].astype('Int64')
shouldn't raise anAttributeError
.print(test)
after assignment should read along the lines ofOutput of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.6.9.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-46-generic
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.1
numpy : 1.16.1
pytz : 2018.9
dateutil : 2.8.0
pip : 19.3.1
setuptools : 41.4.0
Cython : None
pytest : 3.10.1
hypothesis : None
sphinx : 1.8.5
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.3.0
html5lib : None
pymysql : 0.9.3
psycopg2 : None
jinja2 : 2.10
IPython : 7.2.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.3.0
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 3.10.1
pyxlsb : None
s3fs : None
scipy : 1.2.0
sqlalchemy : 1.2.17
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None
The text was updated successfully, but these errors were encountered: