← floor operator page · numeric/floor/comp/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

floor on a component inside calc.

Manual:

Floor, Example 2, output verbatim: "The operator floor returns the greatest integer which is smaller than or equal to op."

Expected:

Me_10 = floor(Me_1) is an Integer: 7, 0, -33 and 44; the other components are kept.

script.vtl ⇩

DS_r := DS_1 [ calc Me_10 := floor (Me_1) ];

input/DS_1.csv ⇩

Id_1Id_2Me_1Me_2
10A7.05.9
10B0.1-5.0
11A-32.217.7
11B44.5-0.3

input/DS_1.json ⇩

{
  "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}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1Me_2Me_10
10A7.05.97
10B0.1-5.00
11A-32.217.7-33
11B44.5-0.344

expected/DS_r.json ⇩

{
  "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"},
        {"name": "Me_10", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}