ā cast operator page Ā· general/cast/number_to_string_mask/decimal_mask
pandas ā Ā· DuckDB ā
cast(Me_1, string, "DD.DDD") on a Number measure: the mask of the page's Example 1.
Type Conversion and Formatting Mask: "āDā one numeric digit (for the mantissa of the scientific notation)" and "ā.ā (dot) can be used as a separator between the integer and the decimal parts".
12.375 and 40.125, and 03.500 from 3.5: two digits, a dot and three digits, a digit for each D, so 3.5 gets a leading zero and two trailing zeros, which the conversion without a mask does not write. The values are exact in binary floating point, so none is rounded.
DS_r := DS_1[calc Me_2 := cast(Me_1, string, "DD.DDD")];
| Id_1 | Me_1 |
|---|---|
| 1 | 12.375 |
| 2 | 40.125 |
| 3 | 3.5 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| 1 | 12.375 | 12.375 |
| 2 | 40.125 | 40.125 |
| 3 | 3.5 | 03.500 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "Integer", "role": "Identifier"},
{"name": "Me_1", "type": "Number", "role": "Measure"},
{"name": "Me_2", "type": "String", "role": "Measure"}
]
}
]
}