-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: to_numeric does not validate the errors keyword #26394
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
How odd! Investigation and PR are welcome! |
The odd thing is that it actually works correctly on a single column:
|
Ah, but the With proper passing through, this works:
|
The second argument of
So this is actually a bug, as @soerendip interested in doing a PR to fix that validation? |
I am, but I am also really, really, really busy right now. So, I can probably work on this in approx 3 weeks. |
In light of #26394 (comment), reopening this issue. |
Anyone doing it? |
@SummerGram : Go for it! |
It works if the args is changed as below:
In this case:
ignore is not passed to the errors in the to_numeric function. From the documentation, args is supposed to be tuple only. Any suggestions? |
@SummerGram it is not about the the |
@jorisvandenbossche the errors variable is retrieved in to_numeric and shown as below:
|
@gfyoung Hi, I have added a defensive check for argument |
From discussion below:
pd.to_numeric
does not validate the value passed to theerrors
keyword, so any random value is interpreted aserrors='coerce'
.Original report:
Code Sample, a copy-pastable example if possible
Problem description
The code above should return:
Strings Numbers
0 'fire' 3838.2
1 'hose' 99.0
Instead it returns:
Strings Numbers
0 NaN 3838.2
1 NaN 99.0
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-48-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.2
pytest: 4.4.1
pip: 19.1
setuptools: 41.0.0
Cython: 0.29.7
numpy: 1.16.3
scipy: 1.2.1
pyarrow: 0.10.0
xarray: 0.12.1
IPython: 7.5.0
sphinx: None
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: 0.4.0
matplotlib: 3.0.3
openpyxl: None
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.7
lxml.etree: 4.3.3
bs4: 4.6.3
html5lib: 0.9999999
sqlalchemy: 1.3.3
pymysql: None
psycopg2: 2.7.5 (dt dec pq3 ext lo64)
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: