I have a .csv file with demand values written like this below, which I need to transform into a dictionary to use in a mathematical optimizer
The dataframe values look like this:
mesoregion service value
0 Metropolitana_SP_ BAU 10000
1 Metropolitana_SP_ VIP / Retention 3000
2 Guarulhos BAU 5000
3 Guarulhos VIP / Retention 1000
Whch i could convert to a dictionary using this command:
demand = demand.set_index (['mesoregion', 'service']). T.to_dict ('list')
It looks like this:
{('Metropolitana_de_SP', 'BAU'): [10000], ('Metropolitana_de_SP', 'VIP / Retencao'): [3000], ('Guarulhos', 'BAU'): [5000], ('Guarulhos', 'VIP / Retention'): [1000]}
However, I need it to look like this (not as a list, but as a value for that tuple):
{('Metropolitana_de_SP', 'BAU'): 10000, ('Metropolitana_de_SP', 'VIP / Retencao'): 3000, ('Guarulhos', 'BAU'): 5000, ('Guarulhos', 'VIP / Retencao') : 1000}
Does anyone know how to help?
Thank you very much