Python Forum
Grouping and summing of dataset - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Grouping and summing of dataset (/thread-30098.html)



Grouping and summing of dataset - jef - Oct-04-2020

I have this dataset that I imported with pandas:

Output:
Date Hour Water 2020-01-01 2 5 2020-01-01 3 45 2020-01-01 4 63 2020-01-01 7 0 2020-01-01 24 35 2020-01-02 1 25
I want to total individual instances of the number of hours and liters. Each "hour" represents an hourly interval on my measuring device. Each "water" is the number of liters of water that flowed through the device in that hour. Thus the desired output is:

Output:
Start date Start hour Hours Elapsed Water 2020-01-01 2 3 113 2020-01-01 24 2 60
If there are missing rows of dates/hours or if there is a row where water=BLANK or water=0, we should skip those.

Whats the easiest way to add this up?