Skip to content

BUG: xs with drop_level=True with a fully specified tuples buggy #6507

Open
@jreback

Description

@jreback

related #6501

In [1]: n=23

In [2]: df = pd.DataFrame({'a':np.append(np.random.randint(0,10,n), -1),
   ...:                    'b':np.append(np.random.randint(0,10,n), -1),
   ...:                    'c':np.append(np.random.randint(0,10,n), -1),
   ...:                    'value':np.random.randint(0,100,n+1)})
In [3]: df.set_index(['a','b','c'], inplace=True)

In [4]: df.sortlevel(inplace = True)

In [7]: df.xs((-1,-1,-1),drop_level=True)
Out[7]: 
value    40
Name: (-1, -1, -1), dtype: int64

In [8]: df.xs((-1,-1),drop_level=True)
Out[8]: 
    value
c        
-1     40

[1 rows x 1 columns]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions