← log operator page · numeric/log/comp_sc/manual_ex_2
pandas ✅ · DuckDB ✅
log of a component to base 2, inside calc, where the result replaces the measure Me_1.
Logarithm, Example 2, output verbatim. As in Example 1, the first operand is the number and the second the base: "log ( 1024, 2 ) gives 10", although the parameter table says the opposite.
Me_1 = log(Me_1, 2) gives 10.0, 6.0 and 5.0 for 1024, 64 and 32; Me_2 is unchanged.
DS_r := DS_1 [ calc Me_1 := log (Me_1, 2) ];
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 1024 | 0.7545 |
| 10 | B | 64 | 13.45 |
| 11 | A | 32 | 1.87 |
{
"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.0 | 0.7545 |
| 10 | B | 6.0 | 13.45 |
| 11 | A | 5.0 | 1.87 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Id_2", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Number", "role": "Measure"},
{"name": "Me_2", "type": "Number", "role": "Measure"}
]
}
]
}