Skip to content

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

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

pambot
Copy link
Contributor

@pambot pambot commented Oct 8, 2018

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.

@pep8speaks
Copy link

pep8speaks commented Oct 8, 2018

Hello @pambot! Thanks for updating the PR.

Comment last updated on October 08, 2018 at 19:04 Hours UTC

@codecov
Copy link

codecov bot commented Oct 8, 2018

Codecov Report

Merging #23044 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #23044   +/-   ##
=======================================
  Coverage   92.19%   92.19%           
=======================================
  Files         169      169           
  Lines       50904    50904           
=======================================
  Hits        46933    46933           
  Misses       3971     3971
Flag Coverage Δ
#multiple 90.61% <100%> (ø) ⬆️
#single 42.31% <0%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/generic.py 96.65% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4482db...fe13f5b. Read the comment docs.

@@ -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.")
Copy link
Contributor

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.

Copy link
Contributor Author

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

@pambot pambot force-pushed the interpolate-object-error-msg branch from 92139d6 to 9af119e Compare October 8, 2018 17:00
Copy link
Member

@jschendel jschendel left a 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?

@jschendel jschendel added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate DataFrame DataFrame data structure labels Oct 8, 2018
@jschendel jschendel added this to the 0.24.0 milestone Oct 8, 2018
@jschendel jschendel added the Error Reporting Incorrect or improved errors from pandas label Oct 8, 2018
@pambot pambot force-pushed the interpolate-object-error-msg branch 2 times, most recently from cffc591 to cf260da Compare October 8, 2018 19:04
@pambot
Copy link
Contributor Author

pambot commented Oct 8, 2018

@jschendel Added the test, please take a look

Copy link
Member

@jschendel jschendel left a 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({
Copy link
Member

@jschendel jschendel Oct 8, 2018

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.

@pambot pambot force-pushed the interpolate-object-error-msg branch from cf260da to fe13f5b Compare October 9, 2018 13:20
@jreback jreback merged commit 362f2e2 into pandas-dev:master Oct 10, 2018
@jreback
Copy link
Contributor

jreback commented Oct 10, 2018

thanks @pambot

tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFrame DataFrame data structure Error Reporting Incorrect or improved errors from pandas Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: Cannot interpolate with all NaNs.
5 participants