Skip to content

Allow passing other arguments to interpolation functions #10383

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
Jun 26, 2015

Conversation

cancan101
Copy link
Contributor

Closes #10378

@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Numeric Operations Arithmetic, Comparison, and Logical operations labels Jun 18, 2015
@jreback
Copy link
Contributor

jreback commented Jun 18, 2015

can you add some tests?

@@ -1734,7 +1735,7 @@ def _interpolate_scipy_wrapper(x, y, new_x, method, fill_value=None,
bounds_error=bounds_error)
Copy link
Member

Choose a reason for hiding this comment

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

Should pass **kwargs, or only support UnivariateSpline? (Also 1749th line)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should support more types. I only wrote one so far.

@sinhrks
Copy link
Member

sinhrks commented Jun 19, 2015

Pls update docstring in generic.py.

@cancan101
Copy link
Contributor Author

Okay. I added tests and updated the docstring. In looking more closely I'm actually not sure what other interpolating methods should be passed the kwargs. Potentially piecewise_polynomial_interpolate but I don't really understand it (#10365). I think interp1d is getting all of the relevant variables.

@@ -2896,6 +2896,7 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
Update the NDFrame in place if possible.
downcast : optional, 'infer' or None, defaults to None
Downcast dtypes if possible.
kwargs : a dictionary of keyword arguments passed into interpolating function.
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be a dictionary I think?
So just "Other keyword arguments are passed to the interpolating function"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@cancan101
Copy link
Contributor Author

Anything else to get this merged? And wow, travis-ci is SLOW at running these tests.

@jreback
Copy link
Contributor

jreback commented Jun 24, 2015

see here: http://pandas.pydata.org/pandas-docs/stable/contributing.html

pls squash.

and travis seems quite chipper lately. We have a quite complicated setup, so takes a bit.

@cancan101
Copy link
Contributor Author

Ok, I'll update the docs and then squash. I usually wait until code is 👍 before squashing to make reviewing easier.

@@ -1365,6 +1365,23 @@ def test_spline(self):
expected = Series([1., 2., 3., 4., 5., 6., 7.])
assert_series_equal(result, expected)

def test_spline_extrapolate(self):
tm.skip_if_no_package('scipy', '0.15', 'setting ext on scipy.interpolate.UnivariateSpline')
s = Series([1, 2, 3, 4, np.nan, 6, np.nan])
Copy link
Contributor

Choose a reason for hiding this comment

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

any other methods take args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I talked about this here: #10383 (comment), I can add kwargs to piecewise_polynomial_interpolate but I am not sure how to test that method.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, why don't you just run it, so will be a smoke test (which asserts that it didn't crash)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually can't get that method to run without the exception I link to in that comment. There seems to be no current test coverage in Pandas of this method.

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh I see. hmm, wonder if that has api changes in recent versions to break this somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LMK what you want to do about this.

Copy link
Member

Choose a reason for hiding this comment

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

I think we can leave that for another PR (as there is an issue for this: #10365), if you don't directly know how to solve it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea how to solve it :-)

@cancan101 cancan101 force-pushed the interp_kwargs branch 2 times, most recently from cacb527 to ffbc52d Compare June 24, 2015 17:41
@cancan101
Copy link
Contributor Author

Squashed and docs.

@cancan101
Copy link
Contributor Author

Anything else remaining to get this merged?

jreback added a commit that referenced this pull request Jun 26, 2015
Allow passing other arguments to interpolation functions
@jreback jreback merged commit d9fba8e into pandas-dev:master Jun 26, 2015
@jreback
Copy link
Contributor

jreback commented Jun 26, 2015

thanks @cancan101

@jreback jreback added this to the 0.17.0 milestone Jun 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants