Code Sample, a copy-pastable example if possible

In [1]: import pandas as pd

In [2]: import numpy as np

In [3]: p = pd.Panel(np.arange(512).reshape((8,8,8)))

In [4]: p.to_frame() Out[4]: ) failed: TypeError: data type "major" not understood>

In [5]: p.axes Out[5]: [RangeIndex(start=0, stop=8, step=1), RangeIndex(start=0, stop=8, step=1), RangeIndex(start=0, stop=8, step=1)]

Issue is similar to Related TypeErrors in multi-indexed DataFrame #12893

Expected Output

Similar to this...

In [6]: p = pd.Panel(np.arange(8).reshape((2,2,2)))

In [7]: p.to_frame() Out[7]:

             0  1
major minor      
0     0      0  4
      1      1  5
1     0      2  6
      1      3  7

In [8]: p.axes Out[8]: [RangeIndex(start=0, stop=2, step=1), RangeIndex(start=0, stop=2, step=1), RangeIndex(start=0, stop=2, step=1)]

output of pd.show_versions()

In [9]: pd.show_versions()

INSTALLED VERSIONS

commit: None python: 2.7.12.candidate.1 python-bits: 64 OS: Linux OS-release: 4.5.0-2-amd64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8

pandas: 0.18.0+git114-g6c692ae nose: 1.3.7 pip: None setuptools: 20.10.1 Cython: None numpy: 1.11.1rc1 scipy: 0.17.1 statsmodels: 0.6.1 xarray: None IPython: 2.4.1 sphinx: None patsy: 0.4.1 dateutil: 2.4.2 pytz: 2015.7 blosc: None bottleneck: None tables: 3.2.2 numexpr: 2.6.0 matplotlib: 1.5.2rc2 openpyxl: 2.3.0 xlrd: 0.9.4 xlwt: 0.7.5 xlsxwriter: None lxml: 3.6.0 bs4: 4.4.1 html5lib: 0.999 httplib2: None apiclient: None sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.8 boto: None pandas_datareader: None

Comment From: sinhrks

Looks to be a repr issue related to MultiIndex.

# OK for creation
df = pd.Panel(np.arange(8*8*8).reshape((8,8,8))).to_frame()

df.head()
#             0   1    2    3    4    5    6    7
# major minor
# 0     0      0  64  128  192  256  320  384  448
#       1      1  65  129  193  257  321  385  449
#       2      2  66  130  194  258  322  386  450
#       3      3  67  131  195  259  323  387  451
#       4      4  68  132  196  260  324  388  452

df
# TypeError: data type "major" not understood

want to do a PR?

Comment From: gdbaldw

@sinhrks Thank you for asking. I'm unfamiliar with the Pandas source, and would need some hand holding on tackling this. Note that as an occasional Pandas user, training me up may be an inefficient use of our time. Nevertheless, am willing.

Comment From: gdbaldw

@sinhrks I suspect its more involved than simply repr, because...

In [8]: df = pd.Panel(np.arange(7*7*7).reshape((7,7,7))).to_frame()

In [9]: df.head()
Out[9]: 
             0   1    2    3    4    5    6
major minor                                
0     0      0  49   98  147  196  245  294
      1      1  50   99  148  197  246  295
      2      2  51  100  149  198  247  296
      3      3  52  101  150  199  248  297
      4      4  53  102  151  200  249  298

In [10]: df
Out[10]: 
              0   1    2    3    4    5    6
major minor                                 
0     0       0  49   98  147  196  245  294
      1       1  50   99  148  197  246  295
      2       2  51  100  149  198  247  296
      3       3  52  101  150  199  248  297
      4       4  53  102  151  200  249  298
      5       5  54  103  152  201  250  299
      6       6  55  104  153  202  251  300
1     0       7  56  105  154  203  252  301
      1       8  57  106  155  204  253  302
      2       9  58  107  156  205  254  303
      3      10  59  108  157  206  255  304
      4      11  60  109  158  207  256  305
      5      12  61  110  159  208  257  306
      6      13  62  111  160  209  258  307
2     0      14  63  112  161  210  259  308
      1      15  64  113  162  211  260  309
      2      16  65  114  163  212  261  310
      3      17  66  115  164  213  262  311
      4      18  67  116  165  214  263  312
      5      19  68  117  166  215  264  313
      6      20  69  118  167  216  265  314
3     0      21  70  119  168  217  266  315
      1      22  71  120  169  218  267  316
      2      23  72  121  170  219  268  317
      3      24  73  122  171  220  269  318
      4      25  74  123  172  221  270  319
      5      26  75  124  173  222  271  320
      6      27  76  125  174  223  272  321
4     0      28  77  126  175  224  273  322
      1      29  78  127  176  225  274  323
      2      30  79  128  177  226  275  324
      3      31  80  129  178  227  276  325
      4      32  81  130  179  228  277  326
      5      33  82  131  180  229  278  327
      6      34  83  132  181  230  279  328
5     0      35  84  133  182  231  280  329
      1      36  85  134  183  232  281  330
      2      37  86  135  184  233  282  331
      3      38  87  136  185  234  283  332
      4      39  88  137  186  235  284  333
      5      40  89  138  187  236  285  334
      6      41  90  139  188  237  286  335
6     0      42  91  140  189  238  287  336
      1      43  92  141  190  239  288  337
      2      44  93  142  191  240  289  338
      3      45  94  143  192  241  290  339
      4      46  95  144  193  242  291  340
      5      47  96  145  194  243  292  341
      6      48  97  146  195  244  293  342

Comment From: sinhrks

Should be related to truncated repr.

p = pd.Panel(np.arange(8).reshape((2, 2, 2)))
p.to_frame()
#              0  1
# major minor
# 0     0      0  4
#       1      1  5
# 1     0      2  6
#       1      3  7

pd.set_option('display.max_rows', 3)
p.to_frame()
# TypeError: data type "major" not understood

Comment From: sinhrks

Found it works on 0.18.1 and latest master (sorry i used older env at first).

Must be the same as #12893. Pls update to 0.18.1 and see the result.