-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
ENH/PERF SparseArray.take indexing #12796
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
Conversation
pandas/sparse/array.py
Outdated
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.
maybe use the shared_docs here?
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.
Done.
pandas/src/sparse.pyx
Outdated
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 think you need to filter first, then call:
inds.searchsorted(indices_to_find) IOW it takes an array as an input (and outputs and array).
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.
@jreback thanks, changed to vectorized version.
95de480 to
33829a0
Compare
|
@jreback rebased, and now green. |
| if allow_fill and fill_value is not None: | ||
| # allow -1 to indicate self.fill_value, | ||
| # self.fill_value may not be NaN | ||
| if (indices < -1).any(): |
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.
so if you can make an issue at some point we can move this stuff (and combin with the guts of assert_fillable_take as an internal function in core/algorighthms.py, but ok for now.
|
thanks @sinhrks |
SparseDataFrameindexing test is not sufficient)git diff upstream/master | flake8 --diffAdded more tests for sparse indexing. Fixed followings:
SparseArray.takehas optimized logic to omit densenp.ndarraycreation.SparseSeires.iloccan work with negative indices. MadeSparseArray.taketo handle negative indices as the same rule asIndex(API: Index.take inconsistently handle fill_value #12676)