How to create a Multi-index dataframe

  • Topic: Python 
  • Thread starter msn009
  • Start date
  • Tags Tags
    Python
1 reply · 2K views · last reply
msn009
Messages
53
Reaction score
6
Attachments
  • Spreadsheet-style grid with a two-level column header: top level 'a' spanning a1, a2, a3 and 'b' spanning b1, b2, b3; row labels 1 to 6 down the left side, with empty cells.
    p1.png
    945 bytes · Views: 587
I haven't gotten into the weeds of this in while, but I think what you're asking is simply not in Pandas. Pandas is designed, in effect, to be excel spreadsheets via python (with the added capabilities that come with it).

Spreadsheets are fundamentally indexed with (i,j) pairs. There is no third index. (You could try to synthetically creating such a thing via a mapping formula that you come up with though that sounds unpleasant).

If you want to use (i,j,k) indexing, this is 3-D tensor territory that is easy to manipulate via arrays in Numpy. It is not Pandas.
 
  • Like
Likes   Reactions: msn009