Python Forum

Full Version: Grouping and summing of dataset
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?