python - Access specific element of array from list django -
i have queryset in view.py:
somevalue = list(a.objects.filter(x=x_number, timestamp__gte=a_time, timestamp__lte=b_time) \ .order_by('timestamp').values_list('timestamp', 'some_index').annotate( some1=dosomething('some_index'), some2=dosomething('some_index_2'), combined_some=(f('some1') + f('some2')) ))
so somevalue looks this:
somevalue = [(datetime.datetime(2017, 7, 20, 23, 53, 51, tzinfo=<utc>), 2l, 10.1, 2.4, 12.5), (datetime.datetime(2017, 7, 20, 23, 54, 51, tzinfo=<utc>), 8l, 5.5, 6.4, 11.9), (datetime.datetime(2017, 7, 20, 23, 55, 51, tzinfo=<utc>), 4l, 7.2, 2.0, 9.2),...]
my goal access somevalue , combined_some this:
combined_some = [(datetime.datetime(2017, 7, 20, 23, 53, 51, tzinfo=<utc>), 12.5), (datetime.datetime(2017, 7, 20, 23, 54, 51, tzinfo=<utc>), 11.9), (datetime.datetime(2017, 7, 20, 23, 55, 51, tzinfo=<utc>), 9.2),...]
is looking ?
combined_some = [(i[0], i[-1]) in somevalue]
Comments
Post a Comment