← union operator page · set/union/two/leftmost_wins_when_measures_differ
pandas ✅ · DuckDB ✅
union(DS_1, DS_2) where ids 2 and 3 are in both operands with different measures (Manual example 2 repeats one data point), to show which one the result keeps. 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.
Union: duplicate Data Points "are filtered by choosing the Data Point belonging to the left most operand Data Set", whatever the other operand holds; the User Manual: "If for a common Data Point one or more dependent variables (Measures and Attributes) have different values in different Data Sets, the Data Point of the leftmost Data Set are returned in the result".
Me_1 is 10, 20, 30 and 41 for ids 1 to 4: ids 2 and 3 keep the values of DS_1, the leftmost operand, and ids 1 and 4 are each in one operand only.
DS_r := union(DS_1, DS_2);
| Id_1 | Me_1 |
|---|---|
| 1 | 10 |
| 2 | 20 |
| 3 | 30 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 2 | 21 |
| 3 | 31 |
| 4 | 41 |
{
"datasets": [
{
"name": "DS_2",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| 1 | 10 |
| 2 | 20 |
| 3 | 30 |
| 4 | 41 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}