-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Interpolation nonnumeric error handling #21773
Conversation
Hello @elapuestojoe! Thanks for updating the PR.
Comment last updated on July 06, 2018 at 18:16 Hours UTC |
pandas/core/generic.py
Outdated
@@ -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): |
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 is_numeric_dtype
intead
pandas/tests/generic/test_generic.py
Outdated
@@ -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 |
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 issue number here
pandas/tests/generic/test_generic.py
Outdated
# 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): |
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.
check the returned message here
pandas/core/generic.py
Outdated
@@ -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 " |
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.
this should be a ValueError
@@ -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 " |
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.
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) | |||
|
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.
this needs to go in pandas/tests/series/test_missing.py
also some tests are failing
closing as stale, if you want to continue working, pls ping and we can re-open. you will need to merge master. |
git diff upstream/master -u -- "*.py" | flake8 --diff