Skip to content
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

BUG/API: assignment of frame in a multi-indexed column frame with a matching level #7655

Closed
jreback opened this issue Jul 3, 2014 · 0 comments · Fixed by #8480
Closed

BUG/API: assignment of frame in a multi-indexed column frame with a matching level #7655

jreback opened this issue Jul 3, 2014 · 0 comments · Fixed by #8480
Labels
API Design Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Jul 3, 2014

http://stackoverflow.com/questions/24553921/pandas-matching-on-level-of-hierarchical-index/24554350#24554350

This should align on the columns axis. Not clear how to specify the alignment level though (e.g. broadcasting would be tricky here).

import numpy as np
import pandas as pd

arrays = [np.hstack([ ['one']*3, ['two']*3]), ['Dog', 'Bird', 'Cat']*2]
columns = pd.MultiIndex.from_arrays(arrays, names=['foo', 'bar'])

df = pd.DataFrame(np.zeros((3,6)),columns=columns,
                  index=pd.date_range('20000103',periods=3))

df['one'] = pd.DataFrame({'Bird' : np.ones(3)*2,
                          'Dog' : np.ones(3),
                          'Cat' : np.ones(3)*3},
                          index= pd.date_range('20000103',periods=3))
df['two'] = pd.DataFrame({'Dog' : np.ones(3)*4,
                          'Bird' : np.ones(3)*5,
                          'Cat' : np.ones(3)*6,},
                          index= pd.date_range('20000103',periods=3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant