Konstantino Sparakis Konstantino Sparakis - 4 months ago 31
Python Question

Resampling Dataframe Time series where column equals value

I have been going through the documentation and trying different things but cant seem to find a solution for this.

I have a df which contains multiple time series. Each time series object consist of a time, price, type of ec2 machine, and location. My goal is to be able to compare the same machine types in different locations and all the machine types within the same location.

enter image description here

I need to resample these time series because the data is only collected when the price is changed, and so in order to do my desired analysis on them I need to resample to line up the times by the hour. I have this following code that will for example, resample one object, which is a specific machine type within a specific region. But how do I resample so that it resamples every Instance in a specific zone separately?



I think you can use:

df.groupby(['AvailabilityZone', 'InstanceType']).resample('H').ffill()