Skip to content

BUG/API: interpolate with limit=0 should mean no interpolation #9217

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

Closed
shoyer opened this issue Jan 9, 2015 · 5 comments
Closed

BUG/API: interpolate with limit=0 should mean no interpolation #9217

shoyer opened this issue Jan 9, 2015 · 5 comments

Comments

@shoyer
Copy link
Member

shoyer commented Jan 9, 2015

Current behavior:

In [28]: s = pd.Series([1, 2, np.nan, np.nan, 5])

In [29]: s
Out[29]:
0     1
1     2
2   NaN
3   NaN
4     5
dtype: float64

In [30]: s.interpolate(limit=0)
Out[30]:
0    1
1    2
2    3
3    4
4    5
dtype: float64

But in fact, limit=0 in contrast to limit=None should mean no interpolation.

@shoyer shoyer added this to the 0.16.0 milestone Jan 9, 2015
@jreback
Copy link
Contributor

jreback commented Jan 9, 2015

very confusing to have None and 0 mean different things

why would you do this?

@shoyer
Copy link
Member Author

shoyer commented Jan 9, 2015

I'm testing the results for different interpolation limits and thought a simple way to trigger no interpolation would be use limit=0, e.g., df = pd.DataFrame({lim: s.interpolate(limit=lim) for lim in range(5)}).

I can see why limit=None makes sense as a sentinel value. But I interpreted limit=0 as "interpolate at most zero values".

@shoyer
Copy link
Member Author

shoyer commented Jan 9, 2015

Another sane API design would be to disallow limit=0 entirely, e.g., assert limit > 0.

@jreback
Copy link
Contributor

jreback commented Jan 9, 2015

ok I understand the reason and it makes sense

though maybe a bit confusing (I get for testing this is useful) but from a user perspective u r like why have an option that makes the function do nothing?

@jreback
Copy link
Contributor

jreback commented Jan 9, 2015

yep maybe limit > 0 makes more sense (but raise a ValueError)

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@jreback jreback modified the milestones: 0.20.0, Next Major Release Dec 27, 2016
AnkurDedania pushed a commit to AnkurDedania/pandas that referenced this issue Mar 21, 2017
…#9217)

closes pandas-dev#9217

Author: Matt Roeschke <[email protected]>

Closes pandas-dev#14994 from mroeschke/fix_9217 and squashes the following commits:

c1790ee [Matt Roeschke] Unify ValueError message and correct cython limits
6f041e6 [Matt Roeschke] Bug: Raise ValueError with interpolate limit = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants