← time_agg operator page · time/time_agg/ds/monthly_measure_to_quarters

Monthly measure to quarters 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

time_agg("Q", DS_1) on a dataset with a monthly time_period measure Me_1 and a quarterly time_period identifier Id_1: the measure is converted, not the identifier.

Manual:

Time aggregation: "The Data Set version acts on a single Measure Data Set of type time, date or time_period and returns a Data Set having the same structure". Its Additional Constraint asks for "exactly one Identifier" of those types, where VTL 2.1 said "exactly one measure": DS_1 meets both, and the example follows the Behaviour.

Expected:

2019M02, 2019M11 and 2019M07 go to 2019Q1, 2019Q4 and 2019Q3, the input duration being "inferred from the internal representation of the value"; converting the quarterly Id_1 instead would leave the months in Me_1.

script.vtl ⇩

DS_r := time_agg("Q", DS_1);

input/DS_1.csv ⇩

Id_1Me_1
2020Q12019M02
2020Q22019M11
2020Q32019M07

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1
2020Q12019Q1
2020Q22019Q4
2020Q32019Q3

expected/DS_r.json ⇩

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