← timeshift operator page · time/timeshift/time_period/manual_ex_3

Manual example 3 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

timeshift(DS_3, 1) on annual time_period series: one period into the future.

Manual:

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

Expected:

Each year moves one year on, 2010 to 2013 becoming 2011 to 2014, with the measures as they were.

script.vtl ⇩

DS_r := timeshift ( DS_3 , 1 );

input/DS_3.csv ⇩

Id_1Id_2Me_1
A2010hello world
A2011
A2012say hello
A2013he
B2010hi,hello!
B2011hi
B2012
B2013hello!

input/DS_3.json ⇩

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

expected/DS_r.csv ⇩

Id_1Id_2Me_1
A2011hello world
A2012
A2013say hello
A2014he
B2011hi,hello!
B2012hi
B2013
B2014hello!

expected/DS_r.json ⇩

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