1

I have a dictionary of dictionary of lists. And when I try to convert it using:

    pd.DataFrame.from_dict()

I obtain something like:

               1               2                 3                   4
    A    [A1a, A1b,..]   [A2a,A2b,A2c..]   [A3a,A3b,A3c...]
    B    [B1a,B1b,..]    [B2a,B2b,B2c..]     ......
    C

And what I would like is to add a second level in the columns.

                1                      2                      3       
          a     b     c         a      b      c        a      b      c
    A    A1a   A1b   A1c       A2a    A2b
    B    B1a   B1b
    C

All the lists are the same length. The index [a,b,c] has not been specified yet but is basically range(14).

Do you have a trick to convert this kind of structure to a MultiIndex DF?

  • Check out this post: http://stackoverflow.com/questions/21443963/pandas-multilevel-column-names – Charlie Haley Feb 23 '16 at 18:46
  • 1
    Possible duplicate of [Nested dictionary to multiindex dataframe where dictionary keys are column labels](http://stackoverflow.com/questions/24988131/nested-dictionary-to-multiindex-dataframe-where-dictionary-keys-are-column-label) – IanS Feb 23 '16 at 20:20

0 Answers0