← setdiff operator page · set/setdiff/two/manual_ex_1
pandas ✅ · DuckDB ✅
setdiff ( DS_1, DS_2 ): five of the six data points of DS_1 are also in DS_2, with the same measures, and DS_2 has one that DS_1 lacks.
Set difference, Example 1, output verbatim: the operator returns a Data Set "containing the Data Points that appear in the first Data Set but not in the second".
the page's one data point, (2012, B, Total, Total) with the measure 10. The (2011, B, Total, Total) of DS_2 is not in DS_1, so it adds nothing.
DS_r := setdiff ( DS_1, DS_2 );
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 10 |
| 2012 | G | Total | Total | 20 |
| 2012 | F | Total | Total | 30 |
| 2012 | M | Total | Total | 40 |
| 2012 | I | Total | Total | 50 |
| 2012 | S | Total | Total | 60 |
{
"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": "Id_4", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2011 | B | Total | Total | 10 |
| 2012 | G | Total | Total | 20 |
| 2012 | F | Total | Total | 30 |
| 2012 | M | Total | Total | 40 |
| 2012 | I | Total | Total | 50 |
| 2012 | S | Total | Total | 60 |
{
"datasets": [
{
"name": "DS_2",
"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": "Id_4", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Id_3 | Id_4 | Me_1 |
|---|---|---|---|---|
| 2012 | B | Total | Total | 10 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Time_Period", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Id_3", "type": "String", "role": "Identifier"},
{"name": "Id_4", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"}
]
}
]
}