I have a pandas dataframe df which looks as shown. (df.to_dict() is given at the end):
model scenario module
AIM/CGE 2.0 ADVANCE_2020_1.5C-2100 wind_total_share high high
SSP1-19 wind_total_share high high
SSP2-19 wind_total_share high high
AIM/CGE 2.1 CD-LINKS_NPi2020_400 wind_total_share high high
TERL_15D_LowCarbonTransportPolicy wind_total_share medium medium
TERL_15D_NoTransportPolicy wind_total_share medium medium
GCAM 4.2 SSP1-19 wind_total_share medium medium
IMAGE 3.0.1 IMA15-AGInt wind_total_share low low
IMA15-Def wind_total_share low low
IMA15-Eff wind_total_share low low
model, scenario, and module are indices while Infrastructure and Investment are two columns of the dataframe. I'd like to convert these two columns into the matrix format, where Infrastructure is similar to x-axis and Investment in similar to Y-axis. Furthermore, both in Infrastructure and Investment, I need to classify them into Low, Medium and High.
In the cells, I'd like to have the name of model and scenarios that satisfy the given category (low/medium/high) for given variable (Infrastructure of Investment) as shown in the screenshot below. There could also be cases when a scenario is high for Infrastructure, but low or medium for Investment and vice versa.

I also want to have another matrix, which shows the number of scenarios that fall into given cell. The second matrix matrices should look something as shown:

I am not familiar with getting such matrix format by modifying the existing pandas dataframe. Are there any functions, or module available that could be used for this purpose? How can I convert my dataframe to the matrix format as shown in the screenshots using Python?
df.to_dict() looks as follows:
{'Infrastructure': {('AIM/CGE 2.0',
'ADVANCE_2020_1.5C-2100',
'wind_total_share'): 'high',
('AIM/CGE 2.0', 'SSP1-19', 'wind_total_share'): 'high',
('AIM/CGE 2.0', 'SSP2-19', 'wind_total_share'): 'high',
('AIM/CGE 2.1', 'CD-LINKS_NPi2020_400', 'wind_total_share'): 'high',
('AIM/CGE 2.1',
'TERL_15D_LowCarbonTransportPolicy',
'wind_total_share'): 'medium',
('AIM/CGE 2.1', 'TERL_15D_NoTransportPolicy', 'wind_total_share'): 'medium',
('GCAM 4.2', 'SSP1-19', 'wind_total_share'): 'medium',
('IMAGE 3.0.1', 'IMA15-AGInt', 'wind_total_share'): 'low',
('IMAGE 3.0.1', 'IMA15-Def', 'wind_total_share'): 'low',
('IMAGE 3.0.1', 'IMA15-Eff', 'wind_total_share'): 'low'},
'Investment': {('AIM/CGE 2.0',
'ADVANCE_2020_1.5C-2100',
'wind_total_share'): 'high',
('AIM/CGE 2.0', 'SSP1-19', 'wind_total_share'): 'high',
('AIM/CGE 2.0', 'SSP2-19', 'wind_total_share'): 'high',
('AIM/CGE 2.1', 'CD-LINKS_NPi2020_400', 'wind_total_share'): 'high',
('AIM/CGE 2.1',
'TERL_15D_LowCarbonTransportPolicy',
'wind_total_share'): 'medium',
('AIM/CGE 2.1', 'TERL_15D_NoTransportPolicy', 'wind_total_share'): 'medium',
('GCAM 4.2', 'SSP1-19', 'wind_total_share'): 'medium',
('IMAGE 3.0.1', 'IMA15-AGInt', 'wind_total_share'): 'low',
('IMAGE 3.0.1', 'IMA15-Def', 'wind_total_share'): 'low',
('IMAGE 3.0.1', 'IMA15-Eff', 'wind_total_share'): 'low'}}
