← count operator page · aggregate/count/ds_group_by/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

count at data set level grouped by Id_1, over one String measure.

Manual:

Counting the number of data points, Example 1, output verbatim: "The operator returns the number of the input Data Points." The result type is dataset { measure<integer> int_var }.

Expected:

int_var = 3 for 2011 and 2 for 2012. With one measure and no null, #1049 gives the same output.

script.vtl ⇩

DS_r := count ( DS_1 group by Id_1 );

input/DS_1.csv ⇩

Id_1Id_2Id_3Me_1
2011AXXiii
2011AYYjjj
2011BYYiii
2012AXXkkk
2012BYYiii

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1int_var
20113
20122

expected/DS_r.json ⇩

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