Dec-16-2017, 09:13 PM
Hello:
I have one list of lists, like this:
The rule is: for every 2 elements in the totals list, find the average of the both elements and save them in another list of lists:
In my above example, I want to get this:
The second one: [3.5, 4.5, 5.5] is the average of [[2, 3, 4], [5, 6, 7]]
The third one: [7.5, 8.0, 7.5] is the average of [[5, 6, 7], [10, 9, 8]]
The last one: [7.0, 7.0, 7.0] is the average of [[10, 9, 8], [4, 5, 6]]
Please advise,
Thanks,
I have one list of lists, like this:
totals = [[1, 2, 3], [2, 3, 4], [5, 6, 7], [10, 9, 8], [4, 5, 6]]I need a function to get a kind of rolling average.
The rule is: for every 2 elements in the totals list, find the average of the both elements and save them in another list of lists:
In my above example, I want to get this:
averages = [ [1.5, 2.5, 3.5], [3.5, 4.5, 5.5], [7.5, 8.0, 7.5], [7.0, 7.0, 7.0]]The first one: [1.5, 2.5, 3.5] is the average of [[1, 2, 3], [2, 3, 4]]
The second one: [3.5, 4.5, 5.5] is the average of [[2, 3, 4], [5, 6, 7]]
The third one: [7.5, 8.0, 7.5] is the average of [[5, 6, 7], [10, 9, 8]]
The last one: [7.0, 7.0, 7.0] is the average of [[10, 9, 8], [4, 5, 6]]
Please advise,
Thanks,