Skip to content

BUG: multilevel indexing with new values #11226

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 Oct 2, 2015 · 1 comment
Closed

BUG: multilevel indexing with new values #11226

jreback opened this issue Oct 2, 2015 · 1 comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex

Comments

@jreback
Copy link
Contributor

jreback commented Oct 2, 2015

In [2]: df = pd.DataFrame(data=[[0, 2, 1], [np.nan, 5, 4]], index=pd.date_range('2014-01-01', '2014-01-2', name='timestamp'), columns=pd.MultiIndex.from_product([['value'], [24, 3766, 5061]], names=[None, 'sid']))

In [3]: df
Out[3]: 
           value          
sid         24   3766 5061
timestamp                 
2014-01-01     0    2    1
2014-01-02   NaN    5    4

In [4]: assets = [3766,5061,123]

In [5]: df.reindex(columns=assets,level=1)
Out[5]: 
           value     
sid         3766 5061
timestamp            
2014-01-01     2    1
2014-01-02     5    4

So this should include 123 as the last column (and all nans) as well.
The indexer returned in np.array([1,2]), but should be np.array([1,2,-1]), see here

only 1 test I could find actually tests this behavior, see here

but only tests that the SAME values are returned, not less or more (which is the point of this issue)

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Difficulty Advanced labels Oct 2, 2015
@jreback jreback added this to the Next Major Release milestone Oct 2, 2015
@jreback
Copy link
Contributor Author

jreback commented Feb 13, 2016

superseded by #12319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Projects
None yet
Development

No branches or pull requests

1 participant