I am trying to loop through iterator with offset [i+1].
I have enumerated my dict. Now I want to access dfc
with function offsetting second dataframe.
dfc = dict()
mydict = {1: 6, 2: 4,3: 10, 4: 7, 5: 3}
for i, (k, v) in enumerate(mydict.items()):
dfc[(i)] = v
print("index: {}, key: {}, value: {}".format(i, k, v))
for i in range(0,5,1):
result[i] = dfc[i] * dfc[i+1]
But I got this error:
File "<ipython-input-139-b31501e8f8af>", line 2, in <module>
result[i] = dfc[i] * dfc[i+1]
KeyError: 5