← symdiff operator page · set/symdiff/two/matched_by_identifiers_not_measures

Matched by identifiers not measures 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

symdiff(DS_1, DS_2) where ids 2 and 3 are in both operands with different measures (in the page's example a shared data point has the same measure in both), to show whether data points are matched by identifiers alone. The measure is 10 * Id_1 + k, with k 0 for DS_1 and 1 for DS_2, so its last digit names the operand.

Manual:

Symmetric difference: "Data Points are compared to one another by Identifier Components"; the result has "all the Data Points dp1 contained in ds1 for which there is no Data Point dp2 in ds2 with the same values for homonym Identifier components", and the same for ds2.

Expected:

ids 1 and 4: 10 from DS_1 and 41 from DS_2. Ids 2 and 3 are in both operands, so they are dropped from both sides although their measures differ.

script.vtl ⇩

DS_r := symdiff(DS_1, DS_2);

input/DS_1.csv ⇩

Id_1Me_1
110
220
330

input/DS_1.json ⇩

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

input/DS_2.csv ⇩

Id_1Me_1
221
331
441

input/DS_2.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1
110
441

expected/DS_r.json ⇩

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