← timeshift operator page · time/timeshift/time_period/manual_ex_4
pandas ✅ · DuckDB ✅
timeshift(DS_4, -1) on an annual and a quarterly series of the same phenomenon A: one period of each series into the past.
Time shift, Example 4, output verbatim: the operator "shifts the reference time Identifier of a number of periods (of the time series) equal to the shiftNumber parameter. If shiftNumber is negative, the shift is in the past".
The years move back one year, 2010 to 2013 becoming 2009 to 2012, and the quarters one quarter, 2010Q1 to 2010Q4 becoming 2009Q4 to 2010Q3.
DS_r := timeshift( DS_4 , -1 );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2011 | |
| A | 2012 | say hello |
| A | 2013 | he |
| A | 2010Q1 | hi, hello! |
| A | 2010Q2 | hi |
| A | 2010Q3 | |
| A | 2010Q4 | hello! |
{
"datasets": [
{
"name": "DS_4",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "Time_Period", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2009 | hello world |
| A | 2010 | |
| A | 2011 | say hello |
| A | 2012 | he |
| A | 2009Q4 | hi, hello! |
| A | 2010Q1 | hi |
| A | 2010Q2 | |
| A | 2010Q3 | hello! |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier"},
{"name": "Id_2", "type": "Time_Period", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"}
]
}
]
}