Skip to content

Indexing columns fail if columns are not unique #1

@kayibal

Description

@kayibal

pd.Index.get_loc returns a Mask if the Index is not unique

import sparsity as sp
import numpy as np
sf = sp.SparseFrame(np.zeros((5,3)), columns=['A', 'A', 'B'])
sf['B'].toarray()
array([ 0.,  0.,  0.,  0.,  0.])
sf['A'].toarray()
Traceback (most recent call last):
  File "/Users/kayibal/virtualenvs/traildb-sparse/lib/python3.5/site-packages/scipy/sparse/csr.py", line 244, in asindices
    x = x.astype(idx_dtype)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'slice'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/kayibal/Code/traildb_to_sparse/traildb_to_sparse/traildb_to_sparse/sparsity/sparse_frame.py", line 455, in __getitem__
    return SparseFrame(self.data[:,idx], index=self.index,
  File "/Users/kayibal/virtualenvs/traildb-sparse/lib/python3.5/site-packages/scipy/sparse/csr.py", line 336, in __getitem__
    col = asindices(col)
  File "/Users/kayibal/virtualenvs/traildb-sparse/lib/python3.5/site-packages/scipy/sparse/csr.py", line 246, in asindices
    raise IndexError('invalid index')
IndexError: invalid index

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions