Hi, I resoleved with :

https://stackoverflow.com/questions/43517901/cumulative-running-sum-with-django-orm-and-postgresql

import numpy as np

import datettime

today = datetime.datetime.date()

raw_data = MyModel.objects.filter('date'=today).values_list('a_number', 
flat=True)

> cumsum = np.cumsum(raw_data)


Il giorno mercoledì 11 marzo 2020 16:42:57 UTC+1, Mario Bisiani ha scritto:
>
> Thank you Micheal. This function is the OVER clause of sql. I think the 
> running sum in a chart is a very common thing and I would like to know if 
> someone has a snippet or piece of library to go "easily".
>
> Thank you for your support.
>
> Il giorno mercoledì 11 marzo 2020 16:32:23 UTC+1, Michael Macintosh ha 
> scritto:
>>
>> You might want to use window functions
>>
>>
>> https://docs.djangoproject.com/en/3.0/ref/models/expressions/#window-functions
>>
>> to calculate the sum per month.  Haven't personally used them yet though.
>> On 3/11/2020 8:27 AM, Mario Bisiani wrote:
>>
>> Yes. I am using Chart.js. Any help?
>>
>> Il giorno giovedì 5 marzo 2020 13:42:18 UTC+1, krnrrr ha scritto: 
>>>
>>> what do you mean by "cumulative"? if we have aggregate sums like
>>>
>>> jan = 100
>>> feb = 150
>>> mar = 120
>>>
>>> you want to have output as
>>>
>>> jan = 100
>>> feb = 250
>>> mar = 370
>>>
>>> ?
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3bb00f84-7a7c-408c-9b17-8cdd51f7bb1f%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/3bb00f84-7a7c-408c-9b17-8cdd51f7bb1f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eaeca64d-5ea3-4130-8cb2-0fd900612a66%40googlegroups.com.

Reply via email to