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

Comments

Projects
None yet
6 participants
@JianxunLi
Copy link

commented Jul 19, 2015

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

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2015

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

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Jul 20, 2015

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 this to the Next Major Release milestone Jul 20, 2015

@souravsingh

This comment has been minimized.

Copy link

commented Jul 23, 2015

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

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Jul 23, 2015

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

This comment has been minimized.

Copy link
Member

commented Jul 23, 2015

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

@jreback

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2015

closed by #10880

@jreback jreback closed this Aug 21, 2015

@ghost

This comment has been minimized.

Copy link

commented Oct 1, 2017

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

@jorisvandenbossche

This comment has been minimized.

Copy link
Member

commented Oct 1, 2017

Please read the responses. You need to pass an order

@jefffriesen

This comment has been minimized.

Copy link

commented Jul 18, 2018

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

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2018

@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
You can’t perform that action at this time.