← timeshift operator page · time/timeshift/date/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

timeshift(DS_2, 2) on annual date series, where "conventionally each period is identified by its last day".

Manual:

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".

Expected:

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.

script.vtl ⇩

DS_r := timeshift ( DS_2 , 2 );

input/DS_2.csv ⇩

Id_1Id_2Me_1
A2010-12-31hello world
A2011-12-31
A2012-12-31say hello
A2013-12-31he
B2010-12-31hi, hello!
B2011-12-31hi
B2012-12-31
B2013-12-31hello!

input/DS_2.json ⇩

{
  "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}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1
A2012-12-31hello world
A2013-12-31
A2014-12-31say hello
A2015-12-31he
B2012-12-31hi, hello!
B2013-12-31hi
B2014-12-31
B2015-12-31hello!

expected/DS_r.json ⇩

{
  "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"}
      ]
    }
  ]
}