Skip to content

ENH: provide squeeze method for removing 1-len dimensions, close (GH #2544) #2734

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
wants to merge 1 commit into from

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Jan 23, 2013

In [1]: p = Panel(randn(3,4,4),items=['ItemA','ItemB','ItemC'],
   ...:                        major_axis=date_range('20010102',periods=4),
   ...:                        minor_axis=['A','B','C','D'])
   ...:

In [2]: p
Out[2]: 
<class 'pandas.core.panel.Panel'>
Dimensions: 3 (items) x 4 (major_axis) x 4 (minor_axis)
Items axis: ItemA to ItemC
Major_axis axis: 2001-01-02 00:00:00 to 2001-01-05 00:00:00
Minor_axis axis: A to D

In [3]: p.reindex(items=['ItemA']).squeeze()
Out[3]: 
                   A         B         C         D
2001-01-02 -1.182806 -1.835015 -0.008415  1.665945
2001-01-03 -0.347332 -0.257820  0.167772 -1.193518
2001-01-04 -0.502643  0.055733  0.733034 -1.070536
2001-01-05 -1.900588 -1.728706  1.060564 -1.138837

In [4]: p.reindex(items=['ItemA'],minor=['B']).squeeze()
Out[4]: 
2001-01-02   -1.835015
2001-01-03   -0.257820
2001-01-04    0.055733
2001-01-05   -1.728706
Freq: D, Name: B

@wesm
Copy link
Member

wesm commented Feb 10, 2013

cherry picked. thanks

@wesm wesm closed this Feb 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants