Skip to content

.loc[item, list] doesn't filter columns #73

@michcio1234

Description

@michcio1234
import sparsity as sp
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.rand(5,5)<0.5, columns=list('ABCDE'))
sf = sp.SparseFrame(df)

sf.loc[2, ['A', 'C', 'E']]

All columns are included in output instead of only selected ones:

     A    B    C    D    E
2  0.0  1.0  0.0  1.0  1.0
[1x5 SparseFrame of type '<class 'float64'>' 
 with 3 stored elements in Compressed Sparse Row format]

Same goes with .loc[list, item] (returns all rows instead of only selected ones):

sf.loc[[1, 2], 'A']

     A
0  0.0
1  1.0
2  1.0
3  1.0
4  1.0
[5x1 SparseFrame of type '<class 'float64'>' 
 with 4 stored elements in Compressed Sparse Row format]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions