Python Forum

Full Version: Time series manipulation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!
We have an optimization model that gives us forecasts of electricity consumption in the future. Because of calculation time we do not use hourly resolution.
Each week is divided into 34 sequences where each sequence represents a certain number of hours. (sum of all 34 sequences will be 168 hours).
The results from the model go 10 years ahead in time. We get over 500 weeks with results, each with 34 sequences and values. Assuming that we always start on Monday of this week. How can I easily create a vector with date and time?
I guess we can make a loop and calculate time based on the difference in hours from the start time. But I have a feeling that this can do in a nicer way in Python with built-in features in Numpy or Pandas?

What will be the best way to do this?

Example. (we want to establish values ​​as in column 3 here)
(The second column contains the number of hours in each of the 34 sequences)

NP index Hours What we are looking for
0 6 2020-03-30 00:00
1 1 2020-03-30 06:00
2 6 2020-03-30 07:00
3 4 2020-03-30 13:00
4 3 2020-03-30 17:00
5 4 2020-03-30 20:00
6 6 2020-03-31 00:00
7 1 2020-03-31 06:00
8 6 2020-03-31 07:00
9 4 2020-03-31 13:00
10 3 2020-03-31 17:00
11 4 2020-03-31 20:00
12 6 2020-04-01 00:00
13 1 2020-04-01 06:00
14 6 2020-04-01 07:00
15 4 2020-04-01 13:00
16 3 2020-04-01 17:00
17 4 2020-04-01 20:00
18 6 2020-04-02 00:00
19 1 2020-04-02 06:00
20 6 2020-04-02 07:00
21 4 2020-04-02 13:00
22 3 2020-04-02 17:00
23 4 2020-04-02 20:00
24 6 2020-04-03 00:00
25 1 2020-04-03 06:00
26 6 2020-04-03 07:00
27 4 2020-04-03 13:00
28 3 2020-04-03 17:00
29 4 2020-04-03 20:00
30 7 2020-04-04 00:00
31 17 2020-04-04 07:00
32 7 2020-04-05 00:00
33 17 2020-04-05 07:00
0 6 2020-04-06 00:00
1 1 2020-04-06 06:00
2 6 2020-04-06 07:00
3 4 2020-04-06 13:00
4 3 2020-04-06 17:00
5 4 2020-04-06 20:00
6 6 2020-04-07 00:00
7 1 2020-04-07 06:00
8 6 2020-04-07 07:00
9 4 2020-04-07 13:00
10 3 2020-04-07 17:00
11 4 2020-04-07 20:00
12 6 2020-04-08 00:00
13 1 2020-04-08 06:00
14 6 2020-04-08 07:00
15 4 2020-04-08 13:00
16 3 2020-04-08 17:00
17 4 2020-04-08 20:00
18 6 2020-04-09 00:00
19 1 2020-04-09 06:00
20 6 2020-04-09 07:00
21 4 2020-04-09 13:00
22 3 2020-04-09 17:00
23 4 2020-04-09 20:00
24 6 2020-04-10 00:00
25 1 2020-04-10 06:00
26 6 2020-04-10 07:00
27 4 2020-04-10 13:00
28 3 2020-04-10 17:00
29 4 2020-04-10 20:00
30 7 2020-04-11 00:00
31 17 2020-04-11 07:00
32 7 2020-04-12 00:00
33 17 2020-04-12 07:00

And so on....