Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FIX: fix interpolate with kwarg limit area and limit direction using pad or bfill #31048
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
FIX: fix interpolate with kwarg limit area and limit direction using pad or bfill #31048
Changes from 12 commits
9afe992
3a191b9
fd5d8e8
26d88ed
6597aca
c536d3c
ed9cf21
2980325
ecf428e
f8a3423
6733186
c5b77d2
0bb36de
a467afd
5466d8c
3e968fc
556a3cf
6c1e429
767b0ca
b82aaff
26ef7b5
b4b6b5a
e259549
8ceff58
7c5ad7d
92148ff
d62e02e
c2473f2
610e347
570e3c2
721304a
73ab1bf
a33f629
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason this logic does not simply belong in interpolate_2d?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or call something like clean_fill_method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limit_direction
has no effect ininterpolate_2d
.My idea was to detect conflicting user input, e.g.
pad
withlimit_direction='backward'
as early as possible in the chain of calls to the many functions that are involved.But I can move the logic to a function like
clean_fill_method
, e.g. calledset_limit_direction
. Should this function belong to generic.py or missing.py?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interpolate_2d is also called from fillna. only NDFrame.interpolate allows limit_direction so does make sense to validate here.
clean_fill_method checks method. probably want to avoid passing more parameters around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls make a method similr to clean_fill_method then, e.g this logic should living pandas/core/missing.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what to do here. after merge with master, there is similar code at this location, but it is not mine...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move this under interpolate_1d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interpolate_1d_fill
is a special case needed byblocks._interpolate_with_fill()
to support the limit kwargs with methodpad
. As you requested in the comment aboveinterpolate_1d_fill
is now called from withininterpolate_2d
which is whatblocks._interpolate_with_fill()
calls.You request, moving it to
missing.interpolate_1d
will, in my opinion, not work, becausemissing.interpolate_1d
is not reached in the call sequence for interpolating with methodpad
sinceblocks.Block.interpolate()
splits up intoblocks.Block._interpolate
(for scipy wrappers) andblocks.Block._interpolate_with_fill
(for pad methods).missing.interpolate_1d
is only called in the former case, i.e. for methods using the scipy wrappers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cchwala interpolate_2d will work on a 1d array. did you investigate applying it along an axis (with masking logic) rather than creating a 1d version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #34749 for alternative implementation calling interpolate_2d instead. interpolate_2d already has the limit logic so no need to use the preserve_nans set based logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the nice solution from #34749 as suggested above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a consequence there is no
interpolate_1d_fill
anymore