I am working on a forecasting model in which I want to use various temporal aggregates of data such as daily, weekly, monthly, quarterly, and yearly.
For creating the forecast models, I am using the library sktime
. For loading the data sktime
is compatible with pandas
dataframes. In order to denote the temporal ordering, sktime
allows the dataframe to be indexed by PeriodIndex
.
For monthly, quarterly, and yearly granularities I do not have a problem setting up the index since the PeriodIndex constructor has parameters for year, quarter, month, and day. However, it does not have a parameter for week.
So I am wondering what I am supposed to do to get around this?
To be specific, I am able to get the other aggregates in the following away, and I would have expected to be able to do something similar for week, but alas I cannot.
# DAILY
dates = ["01/01/2000", "02/01/2000", "25/01/2000", "01/01/3005"]
pd.PeriodIndex(dates, freq='d')
# MONTHLY
pd.PeriodIndex(year=[2000]*12, month=[1,2,3,4,5,6,7,8,9,10,11,12], freq='w')
# QUARTERLY
pd.PeriodIndex(year=[2000,2000,2000,2000], quarter=[1,2,3,4])
...
I assume week is not as straightforward since some years have 52 weeks and others 53.