I have a Python dictionary with the following form:
data = {'2022-01-01': [123, 456], '2022-01-02': [789, 120], ... }
I am trying to loop over the dictionary data and divide the two numbers contained in the lists (e.g. 123/456, 789/120, etc.) with the following:
for values in len(range(data)):
ratio = values[0]/values[1]
But I get a TypeError saying that the dict object cannot be interpreted as an integer. My numbers are clearly integers. Is this not the correct way to loop across a dictionary?
Also, is there a way that I can store the resulting ratio along with the dates in either a new dictionary or a pandas data frame?