I have a dataframe like below:
data = {'ID': [1,2,3,4,5],
'NODE_ID': [10,10,20,15,20],
'TYPE': ['a','a','b','a','b'],
'DATE': ['2021-12-02','2021-12-02','2021-12-02','2021-12-03','2021-12-02'],
'HOUR': [0,0,3,2,3],
'EVENTS_COUNT': [10,15,10,21,12]
}
df = pd.DataFrame(data,columns=['ID','NODE_ID', 'TYPE', 'DATE', 'HOUR', 'EVENTS_COUNT'])
I have two different TYPE
- a
and b
. I want to create a dataframe out of this so I have a sum of each TYPE
(a
and b
) for the group of NODE_ID
, DATE
, HOUR
.
The expected output is
Can you please suggest how to do this?
EDIT: Updated the expected output.