We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
when pd.to_numeric is called with errors='coerce' on a DataFrame, it doesn't raise and just returns the original DataFrame.
pd.to_numeric
errors='coerce'
DataFrame
This may be related to the discussion here #11221 as this function currently doesn't support anything more than 1-d.
In [1]: import pandas as pd In [2]: df = pd.DataFrame({'a': [1, 2, 'foo'], 'b': [2.3, -1, 'bar']}) In [3]: df Out[3]: a b 0 1 2.3 1 2 -1 2 foo bar In [4]: pd.to_numeric(df) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-4-9febd95a7c0a> in <module>() ----> 1 pd.to_numeric(df) /Users/mortada_mehyar/code/github/pandas/pandas/tools/util.py in to_numeric(arg, errors) 94 conv = lib.maybe_convert_numeric(arg, 95 set(), ---> 96 coerce_numeric=coerce_numeric) 97 except: 98 if errors == 'raise': /Users/mortada_mehyar/code/github/pandas/pandas/src/inference.pyx in pandas.lib.maybe_convert_numeric (pandas/lib.c:52369)() 518 cdef int64_t iINT64_MIN = <int64_t> INT64_MIN 519 --> 520 def maybe_convert_numeric(object[:] values, set na_values, 521 bint convert_empty=True, bint coerce_numeric=False): 522 ''' ValueError: Buffer has wrong number of dimensions (expected 1, got 2) In [5]: pd.to_numeric(df, errors='coerce') Out[5]: a b 0 1 2.3 1 2 -1 2 foo bar
Note that the last expression doesn't raise but the previous one does.
Seems like we should either
NDFrame
The text was updated successfully, but these errors were encountered:
best to raise for non 1-d (and check pd.to_datetime/to_timedelta) for the same
Sorry, something went wrong.
sounds good, I'll send a PR
BUG: to_numeric should raise if input is more than one dimension pand…
dc2a5b3
…as-dev#11776
Merge pull request #11780 from mortada/to_numeric_should_raise_on_df
fbb09f4
BUG: to_numeric should raise if input is more than one dimension #11776
Successfully merging a pull request may close this issue.
when
pd.to_numeric
is called witherrors='coerce'
on aDataFrame
, it doesn't raise and just returns the originalDataFrame
.This may be related to the discussion here #11221 as this function currently doesn't support anything more than 1-d.
Note that the last expression doesn't raise but the previous one does.
Seems like we should either
pd.to_numeric
work withDataFrame
orNDFrame
in generalDataFrame
or something more than 1-d is passedThe text was updated successfully, but these errors were encountered: