Skip to content
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: #44334

Closed
3 tasks done
blenq opened this issue Nov 6, 2021 · 2 comments
Closed
3 tasks done

BUG: #44334

blenq opened this issue Nov 6, 2021 · 2 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request NA - MaskedArrays Related to pd.NA and nullable extension arrays

Comments

@blenq
Copy link

blenq commented Nov 6, 2021

  • 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 master branch of pandas.

Reproducible Example

import pandas as pd

# regular integer works
s = pd.Series([1, 3, "45345"])
s.astype("int64")

# nullable integer fails with exception
s = pd.Series([1, 3, "45345"])
s.astype("Int64")

Issue Description

Conversion of strings with valid integer numeric content to nullable integer fails with "TypeError: cannot safely cast non-equivalent object to int64".

Exception raised pandas/core/arrays/integer.py", line 136, in safe_cast

Expected Behavior

IMHO conversion of valid strings to nullable integer should succeed, to be consistent with regular integers.

Installed Versions

Besides the versions used below (python3.9 from Ubuntu repo and pandas master branch from Github), it also fails with python3.7 (self compiled), python3.8 and 3.9 (from Ubuntu repo) and python3.10 (self compiled) with pandas installed from pypi (version 1.3.4).

INSTALLED VERSIONS

commit : 057c6f8
python : 3.9.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.11.0-38-generic
Version : #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.4.0.dev0+1053.g057c6f81b4
numpy : 1.21.4
pytz : 2021.3
dateutil : 2.8.2
pip : 20.0.2
setuptools : 44.0.0
Cython : 0.29.24
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

@blenq blenq added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 6, 2021
@mzeitlin11
Copy link
Member

Thanks @blenq for the report! Going to close as a duplicate of #41060 / #37626

@mzeitlin11 mzeitlin11 added Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request NA - MaskedArrays Related to pd.NA and nullable extension arrays and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 6, 2021
@mzeitlin11 mzeitlin11 added this to the No action milestone Nov 6, 2021
@blenq
Copy link
Author

blenq commented Nov 6, 2021

Great. I had searched for a similar bug report, but apparently overlooked the issues you mentioned. Thnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

No branches or pull requests

2 participants