Skip to content
Advertisement

Pandas dataframe: Sum up rows by date and keep only one row per day without timestamp

I have such a dataframe:

JavaScript

What I want to get is a new dataframe which looks like this

JavaScript

I want to get a new dataframe df1 where all the entries of one day are summed up in y and I only want to keep one column of this day without a timestamp.

What I did so far is this:

JavaScript

24 because I have 24 entries every day (for every hour). I get the correct sum for every day but I also get 24 rows for every day together with the existing timestamps. How can I achieve what I want?

Advertisement

Answer

If need sum all values per days then filtering first 24 rows is not necessary:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement