Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

df.describe() clobbers columns.names #11517

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
dragoljub opened this issue Nov 4, 2015 · 2 comments
Closed

df.describe() clobbers columns.names #11517

dragoljub opened this issue Nov 4, 2015 · 2 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@dragoljub
Copy link

I recently migrated some of my code to Pandas 0.17.0. I found that the df.describe() method is clobbering index names when used after a transpose. Here I'm just using transpose as an easy way to create multi-index column names.

Pandas 0.17.0
Numpy 1.9.2

import pandas as pd
import numpy as np

df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
                          'foo', 'bar', 'foo', 'foo'],
                    'B' : ['one', 'one', 'two', 'three',
                          'two', 'two', 'one', 'three'],
                    'C' : np.random.randn(8),
                    'D' : np.random.randn(8)})

# Create Multi Index For Rows
In [11]: df.groupby(['A', 'B']).mean().index.names
Out[11]: FrozenList([u'A', u'B'])

# Transposing the row index to column names works.
In [31]: df.groupby(['A', 'B']).mean().T.columns.names 
Out[31]: FrozenList([u'A', u'B'])

# After the describe() method the column names are dropped.
In [23]: df.groupby(['A', 'B']).mean().T.describe().columns.names 
Out[23]: FrozenList([None]) # In Pandas 0.13.1 the column names were preserved.

@jreback
Copy link
Contributor

jreback commented Nov 4, 2015

yeh, needs to be set after the describe operation. Pull-requests welcome!

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Nov 4, 2015
@jreback jreback added this to the Next Major Release milestone Nov 4, 2015
@jreback jreback modified the milestones: 0.17.1, Next Major Release Nov 8, 2015
@jreback
Copy link
Contributor

jreback commented Nov 10, 2015

closed by #11546

@jreback jreback closed this as completed Nov 10, 2015
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
Projects
None yet
Development

No branches or pull requests

2 participants