← time_agg operator page · time/time_agg/comp/mixed_periods_to_years

Mixed periods to years 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

time_agg("A", Me_1) inside calc, as the page's ds_2 := ds_1[calc Me1 := time_agg(“M”,Me1)], on a quarter, a month and a semester.

Manual:

Time aggregation: "On time_period type, the operator maps the input value into the comprising larger time period specified by the periodIndTo parameter", and the input duration "can be inferred from the internal representation of the value".

Expected:

Each value goes to its year, whatever its own indicator: 2010Q2, 2011M07 and 2012S2 give 2010, 2011 and 2012, a Time_Period Me_2, as the operator "returns a scalar of the corresponding type".

script.vtl ⇩

DS_r := DS_1[calc Me_2 := time_agg("A", Me_1)];

input/DS_1.csv ⇩

Id_1Me_1
12010Q2
22011M07
32012S2

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Time_Period", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2
12010Q22010
22011M072011
32012S22012

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "Time_Period", "role": "Measure"},
        {"name": "Me_2", "type": "Time_Period", "role": "Measure"}
      ]
    }
  ]
}