Skip to content
Advertisement

Downsampling time series data in pandas

I have timeseries data that looks like this:

JavaScript

I would like to downsample my data from 15-minute frequencies to 1-hour frequencies. So, the first 4 rows above would be summed under 00:00 timestamp, then next 4 rows would be combined under 01:00.

JavaScript

Is there an efficient way to make this happen?

Advertisement

Answer

Look at pandas.DataFrame.resample

JavaScript

would result in

JavaScript

All you need is to get a dataframe with a datetime index.

Advertisement