I am working with a dictionary where each key contain a list of tuples. It looks like this:
dict1 = {'key1': [(time1, value1), (time2, value2), (time3, value3)],
'key2': [(time4, value4), (time5, value5), (time6, value6)],
'key3': [(time7, value7), (time8, value8), (time9, value9)], ...}
What is wish to do for each key is to find the largest drop in 'valueX' from 'timeX' to 'timeY'.
The tuples are orderes so that
time1 < time2 < time3
And it is (typically) true that
value1 > value2 > value3
Both things are true for all keys.
So looking at the first key, what I wish to do is to calculate
value2 - value1 and value3 - value2
And save the times that the biggest drop occurs. Let's say that
value2 - value1 > value3 - value2
Then I wish to save time1 and time2, since it was between those two time values that the largest drop occured.
I am thinking to use a for-loop like the following:
for key in dict1:
for i in dict1[key]:
But I cannot figure out how to
1) loop through the values, calculate the difference between the present value and the past value, save this and compare it the the largest drop that has been observed
2) to save the times that correspond to the largest drop in 'value'.
I hope you can help me out here. Thanks a lot.