I'm sure this has been asked & answered before but I'm probably phrasing my question wrong.
I have the following DataFrame:
article day views
0 729910 13 162
1 729910 14 283
2 730855 13 1
3 731449 13 2
I want to have a single row per value in article, and to have a views
/total_views
column that sums views
number for each occurrence of the article in the row.
So the output should be this (day
doesn't matter for me here):
article views
0 729910 445 (162 + 283)
1 730855 1
2 731449 2
The closest I got is:
parsed_report_df.groupby(['article', 'day'])['views'].sum()
Which yields:
article day
729910 13 162
14 283
730855 13 1
731449 13 2
735682 12 1
but I just need the same for views
every different day
for each article
.