← parentheses operator page · general/parentheses/ds/manual_ex_1
pandas ✅ · DuckDB ✅
(DS_1 + DS_2) * DS_2: the sum in the parentheses comes first, then the product with DS_2, on the data points that the operands share.
Parentheses, Example 1, output verbatim: "The part of the expression inside the parentheses is evaluated before the part outside of the parentheses."
Only (10, A) and (11, B) are in both datasets: Me_1 is (5 + 10) * 10 = 150 and (4 + 6) * 6 = 60, an Integer, and Me_2 is (5.0 + 3.0) * 3.0 = 24.0 and (20.3 + 7.0) * 7.0 = 191.1, a Number. Without the parentheses, (10, A) would give 105 and 14.0.
DS_r := (DS_1 + DS_2) * 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 | 150 | 24.0 |
| 11 | B | 60 | 191.1 |
{
"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"}
]
}
]
}