'groupby date and then sum last date

enter image description here

anyone can help me, please, how come the column 'recovered' doesnt work I just check that column have another value any better code to show it works



Solution 1:[1]

first of all, let's make a numeric date and add it to our data frame.

 data['DateYMD'] = data['Date'].map(lambda date: 10000*date.year + 100*date.month + date.day)

then use groupby on DateYMD for Data separation by date and sum Recovered. Note that we use .reset_index for a cleaner output.

 rec_sum = data.groupby(['DateYMD'])['Recovered'].sum().reset_index()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Csala