Skip to content
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

ENH/PERF SparseArray.take indexing #12796

Closed
wants to merge 1 commit into from

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Apr 4, 2016

Added more tests for sparse indexing. Fixed followings:

@sinhrks sinhrks added Testing pandas testing functions or related to the test suite Indexing Related to indexing on series/frames, not to indexes themselves Performance Memory or execution speed performance Sparse Sparse Data Type labels Apr 4, 2016
@sinhrks sinhrks added this to the 0.18.1 milestone Apr 4, 2016
@@ -307,13 +316,14 @@ def _get_val_at(self, loc):
else:
return _index.get_value_at(self, sp_loc)

def take(self, indices, axis=0):
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

ind_val = indexer[i]
if ind_val < 0 or self.length <= ind_val:
results[i] = -1
else:
Copy link
Contributor

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).

Copy link
Member Author

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.

@sinhrks sinhrks force-pushed the sparse_test_at branch 2 times, most recently from 95de480 to 33829a0 Compare April 6, 2016 19:43
@sinhrks
Copy link
Member Author

sinhrks commented Apr 7, 2016

@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():
Copy link
Contributor

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.

@jreback jreback closed this in c90cdde Apr 7, 2016
@jreback
Copy link
Contributor

jreback commented Apr 7, 2016

thanks @sinhrks

@sinhrks sinhrks deleted the sparse_test_at branch April 7, 2016 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Performance Memory or execution speed performance Sparse Sparse Data Type Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants