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

enhancement: Interpolate_by support float in the by column + extrapolate_flat option #17952

Closed

Conversation

agossard
Copy link
Contributor

This addresses https://github.com/pola-rs/polars/issues/16794. Floats are now supported in the by expression of interpolate_by, and I also added the ability to extrapolate in the regions before and after the start of the by column, by just extending the lowest/highest value of the expressions (consistent with numpy interp function defaults, I believe).

This is my first PR, so I'm not totally sure what's going on. Running the test suite yields many failures, but most of them seem very unlikely to be related to my changes.

One test that is failing in test_interpolate_by. It is not correctly raising the error that it is looking for here:

s = pl.Series([1, None, 3])
by = pl.Series([1, 2])
with pytest.raises(InvalidOperationError, match=r"\(3\), got 2"):
    s.interpolate_by(by)

But I am having trouble understanding where this code goes or debugging it, tbh. Anyway, hoping someone can help.

@agossard agossard changed the title Enhancement: Interpolate_by support float in the by column + extrapolate_flat option enhancement: Interpolate_by support float in the by column + extrapolate_flat option Jul 31, 2024
@MarcoGorelli
Copy link
Collaborator

thanks @agossard !

Could you split this PR up into two please?

  • support float in the by column
  • add extrapolate_flat option

@agossard
Copy link
Contributor Author

Sure. Will try to work on it tonight.

@agossard agossard closed this Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants