-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN GH22985 Fixed interpolation with object error message #23044
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
CLN GH22985 Fixed interpolation with object error message #23044
Conversation
Hello @pambot! Thanks for updating the PR.
Comment last updated on October 08, 2018 at 19:04 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #23044 +/- ##
=======================================
Coverage 92.19% 92.19%
=======================================
Files 169 169
Lines 50904 50904
=======================================
Hits 46933 46933
Misses 3971 3971
Continue to review full report at Codecov.
|
pandas/core/generic.py
Outdated
@@ -6387,7 +6387,8 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False, | |||
|
|||
if _maybe_transposed_self._data.get_dtype_counts().get( | |||
'object') == len(_maybe_transposed_self.T): | |||
raise TypeError("Cannot interpolate with all NaNs.") | |||
raise TypeError("Cannot interpolate with all objects. Try setting" | |||
"the index dtype to a numeric one.") |
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.
I may be wrong, but I don't think it's the index dtype that matters here. I think it's the dtypes of the dataframe. So maybe something like
Cannot interpolate with all object-dtype columns.
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.
No, you're probably right - I was inferring based on the other error messages
92139d6
to
9af119e
Compare
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.
Thanks! Can you add a test to tests/frame/test_missing.py
that reproduces the error and verifies that the message is as expected with tm.assert_raises_regex
?
cffc591
to
cf260da
Compare
@jschendel Added the test, please take a look |
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.
LGTM. One small comment:
@@ -814,6 +814,18 @@ def test_interp_raise_on_only_mixed(self): | |||
with pytest.raises(TypeError): | |||
df.interpolate(axis=1) | |||
|
|||
def test_interp_raise_on_all_object_dtype(self): | |||
df = DataFrame({ |
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.
Can you add the GitHub issue number as a comment? See two tests below for an example. It's useful if someone makes changes that cause this test to break, as it allows them to quickly find the discussion and context for the test.
cf260da
to
fe13f5b
Compare
thanks @pambot |
git diff upstream/master -u -- "*.py" | flake8 --diff
It looks like the problem with #22985 is mostly the mismatch between the input trigger and the error message, so this is just a tiny hotfix.