Skip to content

ENH: allow get to take an axis argument #6703

Closed
@jreback

Description

@jreback

http://stackoverflow.com/questions/22636487/selection-in-multi-indexed-dataframe-when-key-does-not-exists/22637762#22637762

In [23]: df = DataFrame({'a':[1,2,3],'b':[1,2,3],'c':[1,2,3]})

In [24]: x = df.set_index(['a','b'])

In [25]: x
Out[25]: 
     c
a b   
1 1  1
2 2  2
3 3  3

[3 rows x 1 columns]

In [26]: x.T.get((1,1))
Out[26]: 
c    1
Name: (1, 1), dtype: int64

In [27]: x.T.get((1,5),default='foo')
Out[27]: 'foo'

x.get((1,5),default='foo',axis=0) should work (still need the info_axis to be the default though)

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions