-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
limiting reindex with MultiIndex ffill/bfill within levels. #10347
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
this is a dupe of #7895
But you actually want it to work with this syntax
I don't think there is an easy way to support a multi-level reindex as you have indicated (and IMHO too complicated). Better to allow a single level fill, which is what you ultimately want). |
Thanks for the comments. The groupby approach you suggested doesn't do quite the same thing - in the example the index being used intentionally does not have the same date values for every name, whereas the groupby approach assumes the same dates for every group. I guess you could then subset the dates based on the exid, but it gets hairy pretty quickly. I did have a look at the issue you referenced but I'm not sure these are the same. #7895 involves taking a multiindex A, and reindexing it with a plain index In conrast, this issue is about taking a multiindex A and reindexing it with a multiindex C with the same number/name/type of levels (i.e. |
well, the interface is simply as I have stated above. So this needs to be addressed in the |
Will take a crack at it, seems like a good reason to figure out how all this stuff works under the covers. |
awesome! |
Thanks for the request, but it appears there hasn't been much interest or activity in this feature for years so closing |
xref #7895
When reindexing on a multiindex with
method='ffill'
ormethod='bfill'
, it would be very useful to be able to restrict the fill to certain groups/levels of the index.For example, consider the following:
Clearly
john
's score on2008-01-01
is not 3, it's NaN. What would be great (ignoring the awful argument name) is something like:This generalizes to indexes with more than two levels. In effect, it amounts to being able to specify a set of boundaries for the ffill/bfill based on changes in level values. I don't think this can be done in a straightforward way with a
groupby(level='name')
because the values of the index in the second level are not the same for every group.The text was updated successfully, but these errors were encountered: