-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Support high precision converters in to_numeric #19463
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
For reasons not entirely clear to me, our A workaround is to use the 'high precision' float parser - some discussion in #17154 about making that the default. data = StringIO("""
a, b
1, 1
1.7976931348623157e+308, 1
""")
pd.read_csv(data, dtype={'a': float, 'b': float}, engine='c', float_precision='high') |
Also applies to pd.to_numeric(['1.7976931348623157e+308'])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
pandas/_libs/src/inference.pyx in pandas._libs.lib.maybe_convert_numeric()
ValueError: Unable to parse string "1.7976931348623157e+308"
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-29-15b8074a875c> in <module>()
----> 1 pd.to_numeric(['1.7976931348623157e+308'])
~\AppData\Local\Continuum\Anaconda3\envs\py36\lib\site-packages\pandas\core\tools\numeric.py in to_numeric(arg, errors, downcast)
131 coerce_numeric = False if errors in ('ignore', 'raise') else True
132 values = lib.maybe_convert_numeric(values, set(),
--> 133 coerce_numeric=coerce_numeric)
134
135 except Exception:
pandas/_libs/src/inference.pyx in pandas._libs.lib.maybe_convert_numeric()
ValueError: Unable to parse string "1.7976931348623157e+308" at position 0 |
this is not a bug, rather the exact reason for the high precision option. there is a similar issue IIRC. see if you can find it. cc @gfyoung |
yeah i think to_numeric should use the high prevsion converters (though not sure if this goes thru the same path) |
AFAICT, the |
Since the csv behavior is expected, repurposing this issue for the to_numeric enhancement |
|
This work!
This fail!
Message: ValueError: cannot safely convert passed user dtype of float64 for object dtyped data in column 0
Full error stack:
pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 38.4.0
Cython: 0.27.3
numpy: 1.14.0
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 5.5.0
sphinx: 1.6.6
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.2
openpyxl: None
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.2.2
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: 0.6.0
The text was updated successfully, but these errors were encountered: