Skip to content

BUG: fully reindexing panel is incorrect when missing items #5905

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 Jan 11, 2014 · 0 comments · Fixed by #5906
Closed

BUG: fully reindexing panel is incorrect when missing items #5905

jreback opened this issue Jan 11, 2014 · 0 comments · Fixed by #5906
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@jreback
Copy link
Contributor

jreback commented Jan 11, 2014

Fully reindexing a panel copies sub-frames when missing top-level items

IOW, this should have a nan frame for 'Item2'

In [1]: df = DataFrame(np.random.randn(4,3))
 [4]: p = Panel({ 'Item1' : df })

In [12]: p['Item2'] = np.nan

In [13]: p
Out[13]: 
<class 'pandas.core.panel.Panel'>
Dimensions: 2 (items) x 4 (major_axis) x 3 (minor_axis)
Items axis: Item1 to Item2
Major_axis axis: 0 to 3
Minor_axis axis: 0 to 2

In [5]:  items = ['Item1','Item2']

In [8]: major_axis = np.arange(4)

In [9]: minor_axis = np.arange(3)

In [10]: result = p.reindex(items=items,major_axis=major_axis,minor_axis=minor_axis)

In [11]: result.ix['Item2']
Out[11]: 
          0         1         2
0  1.420715  0.972559 -1.334794
1 -0.165063 -1.811950 -1.107652
2 -1.412676  0.376777 -0.521125
3  2.119229  1.221648 -1.078299

[4 rows x 3 columns]

In [14]: p['Item2']
Out[14]: 
    0   1   2
0 NaN NaN NaN
1 NaN NaN NaN
2 NaN NaN NaN
3 NaN NaN NaN

[4 rows x 3 columns]
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 Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant