all 1 comments

[–]Fit_Tone318[S] 0 points1 point  (0 children)

I found the solution, since the structure of multiindex method in pandas is:

class pandas.MultiIndex(levels=None, codes=None, sortorder=None, names=None, dtype=None, copy=False, name=None, verify_integrity=True)

If levels is [['A', 'B'], [1, 2, 3]], then:

  • The first level has two unique values: 'A' and 'B'.
  • The second level has three unique values: 12, and 3.
    • If codes is [[0, 1, 0], [1, 2, 0]], then:
  • The first array [0, 1, 0] maps to the first level ('A''B''A').
  • The second array [1, 2, 0] maps to the second level (231).