← subtraction operator page · numeric/subtraction/ds_ds/manual_ex_1
pandas ✅ · DuckDB ✅
each measure of DS_2 subtracted from the same measure of DS_1, on the data points that the two datasets share.
Subtraction, Example 1, output verbatim: "The operator subtraction returns the difference of two numbers."
only (10, A) and (11, B) are in both datasets: 5 - 10 = -5 and 5.0 - 3.0 = 2.0; 4 - 6 = -2 and 20.3 - 7.0 = 13.3.
DS_r := DS_1 - DS_2;
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 5 | 5.0 |
| 10 | B | 2 | 10.5 |
| 11 | A | 3 | 12.2 |
| 11 | B | 4 | 20.3 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 10 | 3.0 |
| 10 | C | 11 | 6.2 |
| 11 | B | 6 | 7.0 |
{
"datasets": [
{
"name": "DS_2",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | -5 | 2.0 |
| 11 | B | -2 | 13.3 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"},
{"name": "Me_2", "type": "Number", "role": "Measure"}
]
}
]
}