'Create DataFrame with MultiIndex of Three Levels, Partially by Product [closed]
I want a DataFrame that has three levels for index, two correlate to each 1:1, name and position, the third is cartesian, dates for each person. I want it to look like this:
| Index 1 | Index 2 | Index 3 | Points | Assists |
|---|---|---|---|---|
| Jim | Forward | 1/1/2022 | 3 | 5 |
| 1/2/2022 | 4 | 7 | ||
| Kerry | Centre | 1/1/2022 | 8 | 1 |
| 1/2/2022 | 2 | 4 | ||
| Bob | Defense | 1/1/2022 | 1 | 9 |
| 1/2/2022 | 2 | 5 |
How can I build this? I don't know how to combine the by_product method of MultiIndex with a by_array or by_tuple method.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
