Skip to content

Interpolation nonnumeric error handling #21773

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

Conversation

kevinislas2
Copy link

@pep8speaks
Copy link

pep8speaks commented Jul 6, 2018

Hello @elapuestojoe! Thanks for updating the PR.

Line 6030:29: E128 continuation line under-indented for visual indent
Line 6031:29: E128 continuation line under-indented for visual indent
Line 6032:29: E128 continuation line under-indented for visual indent

Line 1024:13: E128 continuation line under-indented for visual indent
Line 1025:13: E128 continuation line under-indented for visual indent
Line 1025:13: E129 visually indented line with same indent as next logical line

Comment last updated on July 06, 2018 at 18:16 Hours UTC

@@ -6024,6 +6024,13 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
raise NotImplementedError("Interpolation with NaNs in the index "
"has not been implemented. Try filling "
"those NaNs before interpolating.")

if not np.issubdtype(index.dtype, np.number):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use is_numeric_dtype intead

@@ -1008,3 +1008,16 @@ def test_pipe_panel(self):

with pytest.raises(ValueError):
result = wp.pipe((f, 'y'), x=1, y=1)

def test_interpolate(self):
# Using a numeric index column
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the issue number here

# Using a non-numeric index column
df = DataFrame([0, 1, np.nan, 3], index=["A", "B", "C", "D"])
series = Series(df[0])
with pytest.raises(TypeError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the returned message here

@@ -6024,6 +6024,13 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
raise NotImplementedError("Interpolation with NaNs in the index "
"has not been implemented. Try filling "
"those NaNs before interpolating.")

if not np.issubdtype(index.dtype, np.number):
raise TypeError("Index column must be numeric when using any "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a ValueError

@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Error Reporting Incorrect or improved errors from pandas labels Jul 6, 2018
@@ -6024,6 +6024,13 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
raise NotImplementedError("Interpolation with NaNs in the index "
"has not been implemented. Try filling "
"those NaNs before interpolating.")

if not is_numeric_dtype(index):
raise ValueError("Index column must be numeric when using any "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have linting issues here

@@ -1008,3 +1008,20 @@ def test_pipe_panel(self):

with pytest.raises(ValueError):
result = wp.pipe((f, 'y'), x=1, y=1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to go in pandas/tests/series/test_missing.py

also some tests are failing

@jreback
Copy link
Contributor

jreback commented Oct 11, 2018

closing as stale, if you want to continue working, pls ping and we can re-open. you will need to merge master.

@jreback jreback closed this Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

pd.Series.interpolate(method="quadratic) Error with non-numeric index column
3 participants