A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/11517 below:

df.describe() clobbers columns.names · Issue #11517 · pandas-dev/pandas · GitHub

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4