← timeshift operator page · time/timeshift/date/manual_ex_2
pandas ✅ · DuckDB ✅
timeshift(DS_2, 2) on annual date series, where "conventionally each period is identified by its last day".
Time shift, Example 2, output verbatim: the operator "shifts the reference time Identifier of a number of periods (of the time series) equal to the shiftNumber parameter".
Each date moves two years on, 2010-12-31 to 2013-12-31 becoming 2012-12-31 to 2015-12-31, with the measures as they were.
DS_r := timeshift ( DS_2 , 2 );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | hello world |
| A | 2011-12-31 | |
| A | 2012-12-31 | say hello |
| A | 2013-12-31 | he |
| B | 2010-12-31 | hi, hello! |
| B | 2011-12-31 | hi |
| B | 2012-12-31 | |
| B | 2013-12-31 | hello! |
{
"datasets": [
{
"name": "DS_2",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "Date", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2012-12-31 | hello world |
| A | 2013-12-31 | |
| A | 2014-12-31 | say hello |
| A | 2015-12-31 | he |
| B | 2012-12-31 | hi, hello! |
| B | 2013-12-31 | hi |
| B | 2014-12-31 | |
| B | 2015-12-31 | hello! |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier"},
{"name": "Id_2", "type": "Date", "role": "Identifier"},
{"name": "Me_1", "type": "String", "role": "Measure"}
]
}
]
}