Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
BUG: asfreq / pct_change strange behavior #7292
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:
changed the title from
pct_change strange behavior
BUG: asfreq / pct_change strange behavior
Jun 26, 2014
I made pull request on June 2nd:
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.