I would like to sum dictionary values over parts of the dictionary sliced by keys. The example below is out of context. I tried to reduce the code to the essential stuff. The problem is depicted in the last line. I try to slice a number of periods and sum the values. I would like to sum dictionary values over part