I have the following dict:
dict = {
"HVAC_flex[1,1]": 8.0,
"HVAC_flex[1,2]": 15.0,
"HVAC_flex[2,1]": 0.0,
"HVAC_flex[2,2]": 0.0,
"DHW_flex[1,1]": 0.0,
"DHW_flex[1,2]": 2.0,
"DHW_flex[2,1]": 4.0,
"DHW_flex[2,2]": 17.0
}
And what I would like to produce is two lists as follows:
HVAC_flex = [ 8.0, 15.0, 0.0, 0.0]
DHW_flex = [ 0.0, 2.0, 4.0, 17.0]
The thing is that the dimensions are dynamically defined, so the dict
may include additional values.
My idea is to search for substrings, like if HVAC_flex
is inluded in the key, then put the value into this list, etc, but I could find a clever way to implement this. Is there a way to do this?