Skip to content
Advertisement

Extrapolating time series data into the future by repeating/scaling existing values

I have hourly data on electricity consumption for a specific day. I would like to use this data to “predict” the hourly electricity consumption for the following days. The value for the following day should be the value from the same hour the day before, multiplied by a scaling factor f (e.g. 2).

The dataframe df that I have looks something like this:

JavaScript

And I would like the output dataframe df_ex to look something like this:

JavaScript

I have tried the following solution (df as defined above):

JavaScript

Which results in:

JavaScript

It appears that my attempt to populate the rows after the first day with values did not succeed. The index is a DateTimeIndex.

Any suggestions on how to solve this would be greatly appreciated!

Advertisement

Answer

To create the data you need to iterate one day at a time.

Assuming that the original data has at least a full day of data then you can do:

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