You can try groupby()
along with sum()
to group the data by the 'date'
column and calculate the total sales per day.
result = df.groupby('date')['sales'].sum().reset_index()
If you'd like to keep date
as the index, you can remove .reset_index()
.