← trunc operator page · numeric/trunc/ds_digits/manual_ex_1
pandas ✅ · DuckDB ✅
trunc to 0 digits on every measure of DS_1.
Truncation, Example 1, output verbatim: "The operator trunc truncates the operand to a number of positions at the right of the decimal point equal to the numDigit parameter."
Me_1 7.5, 7.1, 36.2 and 44.5 give 7.0, 7.0, 36.0 and 44.0; Me_2 5.9, 5.5, 17.7 and 24.3 give 5.0, 5.0, 17.0 and 24.0. Both stay Number, as numDigit is given.
DS_r := trunc(DS_1, 0);
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 7.5 | 5.9 |
| 10 | B | 7.1 | 5.5 |
| 11 | A | 36.2 | 17.7 |
| 11 | B | 44.5 | 24.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": "Number", "role": "Measure", "nullable": true},
{"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Id_2 | Me_1 | Me_2 |
|---|---|---|---|
| 10 | A | 7.0 | 5.0 |
| 10 | B | 7.0 | 5.0 |
| 11 | A | 36.0 | 17.0 |
| 11 | B | 44.0 | 24.0 |
{
"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"}
]
}
]
}