Skip to content

DataFrame.pct_change should default fill_method=None instead of 'pad' #28461

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
selik opened this issue Sep 16, 2019 · 9 comments
Closed

DataFrame.pct_change should default fill_method=None instead of 'pad' #28461

selik opened this issue Sep 16, 2019 · 9 comments
Labels
Duplicate Report Duplicate issue or pull request

Comments

@selik
Copy link
Contributor

selik commented Sep 16, 2019

Both DataFrame.pct_change and Series.pct_change should have default behavior that matches the "obvious" implementation:

lag = series.shift(1)
change = (series - lag) / lag

Unfortunately, the default behavior is set to fill_method='pad' which surprises many people (#6389). We should start a deprecation cycle to change the default to behave as expected, fill_method=None. I don't believe this will be disruptive, as most people think that's how it behaves currently, as far as I know.

@WillAyd
Copy link
Member

WillAyd commented Sep 16, 2019

Can you add a reproducible example? It's not quite clear from the code what you would be looking for.

FWIW #25291 has some new functionality which maybe covers what you are looking for, though that PR has gone stale. If it covers it would certainly welcome you picking that one up

@selik
Copy link
Contributor Author

selik commented Sep 16, 2019

Looks like @TomAugspurger made a comment to this effect on that PR. I'll check it out... someday :-) .

@WillAyd WillAyd added the Duplicate Report Duplicate issue or pull request label Sep 16, 2019
@WillAyd
Copy link
Member

WillAyd commented Sep 16, 2019

OK - closing this as a duplicate of what the PR already solves then, but again if it's something different feel free to provide a reproducible code sample with expected values and can reopen

@WillAyd WillAyd closed this as completed Sep 16, 2019
@selik
Copy link
Contributor Author

selik commented Sep 16, 2019

Ah, no, I don't think that PR was meant to address this issue directly. There happened to be a discussion of this issue as related to PR #25291, in that there's a discussion of what the best default should be. That PR addresses #25006, which looks at the behavior of fill_method='pad'.

@selik
Copy link
Contributor Author

selik commented Sep 16, 2019

I misspoke earlier. The referenced PR does not put the default behavior into a deprecation cycle, which is the goal of this issue.

@WillAyd WillAyd reopened this Sep 17, 2019
@maartenb
Copy link

As this is not a duplicate, can the duplicate label be removed?

What needs to be done to get this issue resolved/implemented?

@jreback
Copy link
Contributor

jreback commented Oct 23, 2019

this is a duplicate of #25006

there is a closed PR that almost ready (referenced from the above issue)

@jreback jreback closed this as completed Oct 23, 2019
@maartenb
Copy link

The approach @selik proposed is different and well defined. If there is a sequence of NaNs it might not make sense to do a pct_change over the gap. Also, it seems that PR for #25006 is not really in play anymore, possibly because it also needs a deprecation period?

@selik
Copy link
Contributor Author

selik commented Oct 24, 2019

@jreback I looked at PR #25006 and don't think it's going to solve this issue. The discussion of that issue does not indicate changing the default behavior from fill_method='pad' to fill_method=None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

4 participants