in Python I have the following multi index data frame:
| level 3 | col 1 | col 1 | col 2 | col 3 | |||
|---|---|---|---|---|---|---|---|
| level 1 | level 2 | level 3 | level 4 | col 1a | col 1b | col 2 | col 3 |
| A | Aa | Aaa | type1 | val 1 | val 2 | val 3 | val 4 |
| A | Aa | Aaa | type2 | val 5 | val 6 | val 7 | val 8 |
| A | Ab | Aab | type1 | val 9 | val 10 | ... | ... |
| A | Ac | Aac | type2 | ... | ... | ... | ... |
| B | Ba | Baa | type1 | ... | ... | ... | ... |
| B | Ba | Bab | type3 | ... | ... | ... | ... |
| C | Ca | Caa | type4 | ... | ... | ... | ... |
To explain the data frame:
- First 2 rows are multi index headers
- First 4 columns are multi index headers
- level 1, 2, 3, 4 and empty spaces are index area
From this list, my aim is to get a dictionary such as:
- First option is A , B or C
- If clicked on A, next choice is Aa , Ab or Ac
- If clicked on Aa, next choice is only Aaa (if only Aaa is available)
- If clicked on Aaa, next choice is type 1 or type 2
- If clicked on type1, next choice is col 1 or col 2 or col3
- If clicked on col1, next choice is col 1a or col 1b
- If clicked on col 1a, we find the val 1 as final output
Please, give me directions on how to do this transformation. Also, new viewpoints and suggestions about how to approach this case is very appreciated as well.