-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: asfreq / pct_change strange behavior #7292
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
Comments
So
Proposed
|
want to do a pr to fix this? |
@shura-v how's this coming? |
@shura-v ? |
I made pull request on June 2nd: |
needs some tests |
Hi, will attempt to work on this issue. reverting. |
since pandas.core.generic.NDFrame.pct_change essentially calls s.shift method to work out pct change, I've looked into how different outputs were produced with difference choices of params. s.shift(periods=5, freq=None) uses the underlying _data block manager to shift values without touching the index. s.shift(freq='5H') calls s.tshift and shift index, hence when calculating pct_change (unshifted divided by shifted frame), the resulting frame will have longer index when shifting with frequencies than when shifting with periods, because the latter scenario, index remains unchanged. So that explains the difference of observations as per earlier discussion. raising PR. reverting. |
In the first case, is it a bug (those NaNs at the end) or a feature? I just don't get the reason behind this behavior:
but this seems ok:
The text was updated successfully, but these errors were encountered: