← timeshift operator page · time/timeshift/time_period/manual_ex_3
pandas ✅ · DuckDB ✅
timeshift(DS_3, 1) on annual time_period series: one period into the future.
Time shift, Example 3, 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, otherwise it is in the future."
Each year moves one year on, 2010 to 2013 becoming 2011 to 2014, with the measures as they were.
DS_r := timeshift ( DS_3 , 1 );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2011 | |
| A | 2012 | say hello |
| A | 2013 | he |
| B | 2010 | hi,hello! |
| B | 2011 | hi |
| B | 2012 | |
| B | 2013 | hello! |
{
"datasets": [
{
"name": "DS_3",
"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 | 2011 | hello world |
| A | 2012 | |
| A | 2013 | say hello |
| A | 2014 | he |
| B | 2011 | hi,hello! |
| B | 2012 | hi |
| B | 2013 | |
| B | 2014 | 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"}
]
}
]
}