Skip to content

ENH: allow get to take an axis argument #6703

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

Closed
jreback opened this issue Mar 25, 2014 · 1 comment
Closed

ENH: allow get to take an axis argument #6703

jreback opened this issue Mar 25, 2014 · 1 comment
Labels
Enhancement Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@jreback
Copy link
Contributor

jreback commented Mar 25, 2014

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)

@jreback jreback added this to the 0.15.0 milestone Mar 25, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@jreback jreback closed this as completed Nov 13, 2015
@jreback
Copy link
Contributor Author

jreback commented Nov 13, 2015

I suppose this could be added as an argument to loc, e.g. default (and handled on missing inputs), though .fillna really does this nicely.

@jorisvandenbossche jorisvandenbossche modified the milestones: No action, Next Major Release Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants