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

BUG: Sparse indexing with bool sparse may be incorrect #13985

Closed
wants to merge 1 commit into from

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Aug 13, 2016

  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

indexing with SparseArray with bool dtype may return incorrect result because of some internal conversions.

arr = pd.SparseArray([1, 2, 3])
indexer = pd.SparseArray([True, False, True], fill_value=False, dtype=bool)

# NG
arr[indexer]
# [2.0, 2.0]
# Fill: nan
# IntIndex
# Indices: array([0, 1], dtype=int32)

# Expected (after this PR)
arr[indexer]
# [1.0, 3.0]
# Fill: nan
# IntIndex
# Indices: array([0, 1], dtype=int32)

@sinhrks sinhrks added Bug Indexing Related to indexing on series/frames, not to indexes themselves Sparse Sparse Data Type labels Aug 13, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Aug 13, 2016
@codecov-io
Copy link

codecov-io commented Aug 13, 2016

Current coverage is 85.28% (diff: 83.33%)

Merging #13985 into master will decrease coverage by <.01%

@@             master     #13985   diff @@
==========================================
  Files           139        139          
  Lines         50206      50211     +5   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          42818      42822     +4   
- Misses         7388       7389     +1   
  Partials          0          0          

Powered by Codecov. Last update 29d9e24...0909fa8

@jreback
Copy link
Contributor

jreback commented Aug 13, 2016

thanks!

@sinhrks sinhrks deleted the sparse_bool_indexing branch August 13, 2016 22:22
jreback pushed a commit that referenced this pull request Aug 20, 2016
Because #13985 has been fixed, ``SparseSeries`` comparison op now can return
``SparseSeries`` (it returns normal ``Series`` on current master).
also fixed a bug when ``SparseArray`` created from ``SparseSeries``
may not inherit ``dtype``.

Author: sinhrks <sinhrks@gmail.com>

Closes #13999 from sinhrks/sparse_comparison and squashes the following commits:

eafc94c [sinhrks] API: SparseSeries comparison now returns sparse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Sparse Sparse Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants