If you have a pandas dataframe with hourly data, the following code snippet will help you to aggregate them into the daily data with average values:
main.py494 chars19 lines
Here, we first convert the 'Date' column to datetime type using pd.to_datetime()
method. Then we set the 'Date' column as the index for resampling the data to daily frequency using resample()
method. Finally, we use mean()
method to calculate the daily average and store the result in a new dataframe.
Note that the code assumes that your original dataframe has columns named "Date" and "Value". You should modify it accordingly if your dataframe has different column names.
I hope it helps!
gistlibby LogSnag