← subtraction operator page · numeric/subtraction/comp_comp/integer_minus_number
pandas ✅ · DuckDB ✅
an Integer component minus a Number component, inside calc.
Subtraction: "If one of the operands is of type number, then the other operand is implicitly cast to number and therefore the result has type number."
Me_3 = Me_1 - Me_2: 2 - 2.5 = -0.5, 4 - 4.0 = 0.0 and 5 - 0.5 = 4.5, a Number; the other components are kept.
DS_r := DS_1[calc Me_3 := Me_1 - Me_2];
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 2 | 2.5 |
| 2 | 4 | 4.0 |
| 3 | 5 | 0.5 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
{"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 | Me_3 |
|---|---|---|---|
| 1 | 2 | 2.500000 | -0.500000 |
| 2 | 4 | 4.000000 | 0.000000 |
| 3 | 5 | 0.500000 | 4.500000 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Integer", "role": "Measure"},
{"name": "Me_2", "type": "Number", "role": "Measure"},
{"name": "Me_3", "type": "Number", "role": "Measure"}
]
}
]
}