Skip to content
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

pd.Series.interpolate(method='spline') Error #10633

Closed
JianxunLi opened this issue Jul 19, 2015 · 10 comments
Closed

pd.Series.interpolate(method='spline') Error #10633

JianxunLi opened this issue Jul 19, 2015 · 10 comments
Labels
Docs Error Reporting Incorrect or improved errors from pandas
Milestone

Comments

@JianxunLi
Copy link

Although in docs it says method='spline' is a choice, but it raises a ValueError.

import numpy as np
import pandas as pd

np.random.seed(1)
s = pd.Series(np.arange(10)**2)
s[np.random.randint(0,9,3)] = np.nan
s.interpolate(method='spline')

# raise ValueError
ValueError: invalid method 'spline' to interpolate.
@jreback
Copy link
Contributor

jreback commented Jul 19, 2015

I believe this was just fixed in master
can u try?

@TomAugspurger
Copy link
Contributor

That's using the scipy interp1d function which requires an order parameter when you call it. order=1 is linear, 2 is quadratic, and 3 is cubic.

If you want we could provide a more informative error message.

@TomAugspurger TomAugspurger added Docs Error Reporting Incorrect or improved errors from pandas labels Jul 20, 2015
@TomAugspurger TomAugspurger added this to the Next Major Release milestone Jul 20, 2015
@souravsingh
Copy link

I would like to work on this bug.How do I start?

@TomAugspurger
Copy link
Contributor

There are some instructions here: https://github.com/pydata/pandas/wiki/Contributing.

For this one you'll need to check if the interpolation method is spline and check if they don't have an order keyword argument.

@jorisvandenbossche
Copy link
Member

Nowadays, there is also a guide in the docs: http://pandas.pydata.org/pandas-docs/stable/contributing.html

@jreback
Copy link
Contributor

jreback commented Aug 21, 2015

closed by #10880

@jreback jreback closed this as completed Aug 21, 2015
@ghost
Copy link

ghost commented Oct 1, 2017

Still fails in version 0.20.3, using the same test code as JianxunLi's.

@jorisvandenbossche
Copy link
Member

Please read the responses. You need to pass an order

@jefffriesen
Copy link

This still fails in 0.22.0 after merging https://github.com/pandas-dev/pandas/pull/10880/files using @JianxunLi 's code. I know you have to pass an order and that does work. But the error when not passing an order still says this without referencing order:

ValueError: invalid method 'spline' to interpolate.

@TomAugspurger
Copy link
Contributor

@jefffriesen do you know of a way to find the required parameters for each interpolation method?

Short of that, we should be raising our exception from the old one. In Python 3 that's

try:
    m = ...
except Exception as e:
    raise ValueError("Invalid method ...") from e

I believe six has ways of doing that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants