I currently have a dict like this (assume many countries, states, and cities):
'USA': {
'Texas': {
'Austin': {
'2017-01-01': 169,
'2017-02-01': 231
},
'Houston': {
'2017-01-01': 265,
'2017-02-01': 310
}
}
I want to create a new dict "grouping by" only country and date, filtering for a given state, so the result would be:
'USA': {
'2017-01-01': 434,
'2017-02-01': 541
}
I can do this by looping over each layer of the dict, but it's hard to read. Is there a way to do this with lambda/map functions instead?
Also, we are unable to use pandas dataframes for other reasons, so I can't use that groupby feature.