← flow_to_stock operator page · time/flow_to_stock/date/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

flow_to_stock(DS_2) on date series, where "conventionally each period is identified by its last day".

Manual:

Flow to stock, Example 2, output verbatim: "the operator perform the cumulative sum from the first Data Point of each time series to each other following Data Point of the same time series."

Expected:

A 2, 7, 4, 13 and B 4, -4, -4, 2; the fourth date of each series is 9999-12-31, as the manual's input has it.

script.vtl ⇩

DS_r := flow_to_stock ( DS_2 );

input/DS_2.csv ⇩

Id_1Id_2Me_1
A2010-12-312
A2011-12-315
A2012-12-31-3
A9999-12-319
B2010-12-314
B2011-12-31-8
B2012-12-310
B9999-12-316

input/DS_2.json ⇩

{
  "datasets": [
    {
      "name": "DS_2",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Id_2", "type": "Date", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Id_2Me_1
A2010-12-312
A2011-12-317
A2012-12-314
A9999-12-3113
B2010-12-314
B2011-12-31-4
B2012-12-31-4
B9999-12-312

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier"},
        {"name": "Id_2", "type": "Date", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}