There is very similar question that I will base on: How to create list from 100 elements to list of 10
In my case list looks like this:
e.g.
a = [[[100], ['Wed Sep 25 13:01:51 2019']],
[[200], ['Wed Sep 25 13:01:51 2019']],
[[300], ['Wed Sep 25 13:01:52 2019']],
[[400], ['Wed Sep 25 13:01:52 2019']],
[[500], ['Wed Sep 25 13:01:53 2019']],
[[600], ['Wed Sep 25 13:01:53 2019']],
[[700], ['Wed Sep 25 13:01:54 2019']]
[[800], ['Wed Sep 25 13:01:54 2019']]]
So as you can see, each sample is taken every half second. I've got problem with proper 'equalizing' of such list. I would like to make another list that will be mean of values with timestamp from first or last row of second that sample was taken.
I tried to edit such converter from attached link on stack, so the outcome of performing this code:
A = [[[100], ['Wed Sep 25 13:01:51 2019']],
[[200], ['Wed Sep 25 13:01:51 2019']],
[[300], ['Wed Sep 25 13:01:52 2019']],
[[400], ['Wed Sep 25 13:01:52 2019']],
[[500], ['Wed Sep 25 13:01:53 2019']],
[[600], ['Wed Sep 25 13:01:53 2019']],
[[700], ['Wed Sep 25 13:01:54 2019']],
[[800], ['Wed Sep 25 13:01:54 2019']]]
B = [sum(A[i:i+2][0][0])/2 for i in range(0, len(A), 2)]
print(B)
Would give desired result like:
b = [[[150], ['Wed Sep 25 13:01:51 2019']],
[[350], ['Wed Sep 25 13:01:52 2019']],
[[550], ['Wed Sep 25 13:01:53 2019']],
[[750], ['Wed Sep 25 13:01:54 2019']]],
Although it gives result:
[50.0, 150.0, 250.0, 350.0]
which is firstly wrong, and secondly without timestamp. What should I modify?