-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix maybe_convert_numeric for unhashable objects #13326
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: Fix maybe_convert_numeric for unhashable objects #13326
Conversation
956f9e3
to
80b8515
Compare
@@ -102,6 +102,12 @@ def test_scientific_no_exponent(self): | |||
result = lib.maybe_convert_numeric(arr, set(), False, True) | |||
self.assertTrue(np.all(np.isnan(result))) | |||
|
|||
def test_convert_non_hashable(self): | |||
arr = np.array([[10.0, 2], 1.0, 'apple']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the issue number here as a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test usage of pd.to_numeric as well (tests in pandas/tools
Current coverage is 84.22%@@ master #13326 diff @@
==========================================
Files 138 138
Lines 50684 50681 -3
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 42684 42682 -2
+ Misses 8000 7999 -1
Partials 0 0
|
@@ -317,6 +317,7 @@ Bug Fixes | |||
- Bug in ``groupby`` where ``apply`` returns different result depending on whether first result is ``None`` or not (:issue:`12824`) | |||
|
|||
|
|||
- Bug in ``pd.to_numeric`` when ``errors='coerce'`` returns same dataframe/series when dataframe/series contains non-hashable objects (:issue:`13324`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug in pd.to_numeric
when errors='coerce'
and input contains non-hashable objects....
8fc536f
to
2db755f
Compare
@jreback i've made the changes you suggested |
# Test for Bug #13324 | ||
arr = np.array([[10.0, 2], 1.0, 'apple']) | ||
result = lib.maybe_convert_numeric(arr, set(), False, True) | ||
np.testing.assert_array_equal(result, np.array([np.nan, 1.0, np.nan])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tm.assert_numpy_array_equal
(we don't use th numpy testing functions at all; in fact there is a check again them; though this one slipped thru)
752ac47
to
bf4f9d8
Compare
looks good. ping when green. |
b09a1b3
to
76a0738
Compare
@RogerThomas thanks! I was just experimenting with something and: so maybe should change this to though can't seem to get this to trigger
|
if you want to see if you can generate a test that makes this fail (not sure). If so , can you do a followup? |
Hey @jreback, I think this is just due to python's syntax parser. In [1]: a = 1
In [2]: a.__hash__
Out[2]: <method-wrapper '__hash__' of int object at 0xa63b00> I don't think this could ever fail |
oh ok that makes sense thanks |
git diff upstream/master | flake8 --diff