← flow_to_stock operator page · time/flow_to_stock/date/manual_ex_2
pandas ✅ · DuckDB ✅
flow_to_stock(DS_2) on date series, where "conventionally each period is identified by its last day".
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."
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.
DS_r := flow_to_stock ( DS_2 );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | 2 |
| A | 2011-12-31 | 5 |
| A | 2012-12-31 | -3 |
| A | 9999-12-31 | 9 |
| B | 2010-12-31 | 4 |
| B | 2011-12-31 | -8 |
| B | 2012-12-31 | 0 |
| B | 9999-12-31 | 6 |
{
"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}
]
}
]
}
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | 2 |
| A | 2011-12-31 | 7 |
| A | 2012-12-31 | 4 |
| A | 9999-12-31 | 13 |
| B | 2010-12-31 | 4 |
| B | 2011-12-31 | -4 |
| B | 2012-12-31 | -4 |
| B | 9999-12-31 | 2 |
{
"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"}
]
}
]
}