Fill time series · fill_time_series
---
config:
flowchart:
useMaxWidth: false
---
flowchart LR
classDef ok fill:#d4edda,stroke:#28a745,color:#000
classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
O["Fill time series · fill_time_series<br/>🟢8"]:::ok
v_default_tp["fill_time_series(DS) on time_period"]:::ok
v_single_tp["fill_time_series(DS, single) on time_period"]:::ok
v_all_tp["fill_time_series(DS, all) on time_period"]:::ok
v_default_date["fill_time_series(DS) on date"]:::ok
v_single_date["fill_time_series(DS, single) on date"]:::ok
v_all_date["fill_time_series(DS, all) on date"]:::ok
v_single_time["fill_time_series(DS, single) on time"]:::ok
v_all_time["fill_time_series(DS, all) on time"]:::ok
v_default_tp --- O
v_single_tp --- O
v_all_tp --- O
v_default_date --- O
O --- v_single_date
O --- v_all_date
O --- v_single_time
O --- v_all_time
click v_default_tp href "#form-default-tp"
click v_single_tp href "#form-single-tp"
click v_all_tp href "#form-all-tp"
click v_default_date href "#form-default-date"
click v_single_date href "#form-single-date"
click v_all_date href "#form-all-date"
click v_single_time href "#form-single-time"
click v_all_time href "#form-all-time"
Types
Takes time, date, time_period · Gives time, date, time_period, any type
Comes from · time, date, time_period — 7 operators in 2 blocks 🟢7
General purpose operators (1) 🟢1
Comes from · operators that return any type (their input's) — 36 operators in 8 blocks 🟢36
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Set operators (4) 🟢4
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Goes to: whatever takes its input's type
Goes to · time, date, time_period — 13 operators in 3 blocks 🟢13
General purpose operators (1) 🟢1
Time operators (11) 🟢11
period_indicatorFlow to stock flow_to_stockStock to flow stock_to_flowTime shift timeshiftTime aggregation time_aggDays between two dates datediffAdd time unit to date dateaddExtract the year getyearExtract the month getmonthExtract the day of the month dayofmonthExtract the day of the year dayofyearDefinitions (VTL-DL) (1) 🟢1
Goes to · operators that take any scalar — 49 operators in 9 blocks 🟢49
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (10) 🟢10
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Clause operators (9) 🟢9
Definitions (VTL-DL) (1) 🟢1
Forms
fill_time_series(DS) on time_period 🟢 · time_period → time_period, any type
Default is all 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_1)withoutlimitsMethodon annual time_period series:Ahas 2010 and 2012,Bhas 2011 and 2012.- Manual:
Fill time series:
limitsMethodhas the “default: all”, and “If limitsMethod is all, the time limits are determined with reference to all the time_series of the Data Set: the limits are the minimum and the maximum values of the reference time Identifier Component of the Data Set.”- Expected:
The limits are 2010 and 2012 for both series, so
Agets 2011 andBgets 2010, whichsinglewould not add; “For the added Data Points, Measures and Attributes assume the null value.”
DS_r := fill_time_series(DS_1);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | 1 |
| A | 2012 | 3 |
| B | 2011 | 5 |
| B | 2012 | 6 |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | 1 |
| A | 2011 | |
| A | 2012 | 3 |
| B | 2010 | |
| B | 2011 | 5 |
| B | 2012 | 6 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
fill_time_series(DS, single) on time_period 🟢 · time_period → time_period, any type
Manual example 5 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_3, single)on annual time_period series.- Manual:
Fill time series, Example 5, output verbatim: “If limitsMethod is single, the time limits are determined with reference to each single time_series of the Data Set: the limits are the minimum and the maximum values of the reference time Identifier Component of the time series.”
- Expected:
A, from 2010 to 2013, gets 2011 andB, from 2011 to 2014, gets 2013, each with a nullMe_1; nothing is added outside the limits of its series.
DS_r := fill_time_series ( DS_3, single );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2012 | say hello |
| A | 2013 | he |
| B | 2011 | hi, hello! |
| B | 2012 | hi |
| B | 2014 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2011 | |
| A | 2012 | say hello |
| A | 2013 | he |
| B | 2011 | hi, hello! |
| B | 2012 | hi |
| B | 2013 | |
| B | 2014 | hello! |
Files: script.vtl · input/DS_3.csv · input/DS_3.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Manual example 7 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_4, single)on an annual and a quarterly series of the same phenomenonA, told apart by their period.- Manual:
Fill time series, Example 7, output verbatim: “If limitsMethod is single, the time limits are determined with reference to each single time_series of the Data Set”, and the reference time Identifier “is increased of one period at a time”.
- Expected:
The annual series gets 2011, between 2010 and 2012, and the quarterly one 2010Q3 and 2011Q1, between 2010Q1 and 2011Q2, each with a null
Me_1.
DS_r := fill_time_series ( DS_4, single );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2012 | say hello |
| A | 2010Q1 | he |
| A | 2010Q2 | hi, hello! |
| A | 2010Q4 | hi |
| A | 2011Q2 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2011 | |
| A | 2012 | say hello |
| A | 2010Q1 | he |
| A | 2010Q2 | hi, hello! |
| A | 2010Q3 | |
| A | 2010Q4 | hi |
| A | 2011Q1 | |
| A | 2011Q2 | hello! |
Files: script.vtl · input/DS_4.csv · input/DS_4.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
fill_time_series(DS, all) on time_period 🟢 · time_period → time_period, any type
Manual example 6 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_3, all)on annual time_period series.- Manual:
Fill time series, Example 6, output verbatim: “If limitsMethod is all, the time limits are determined with reference to all the time_series of the Data Set: the limits are the minimum and the maximum values of the reference time Identifier Component of the Data Set.”
- Expected:
The limits are 2010 and 2014 for both series:
Agets 2011 and 2014,Bgets 2010 and 2013, each with a nullMe_1.
DS_r := fill_time_series ( DS_3, all );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2012 | say hello |
| A | 2013 | he |
| B | 2011 | hi, hello! |
| B | 2012 | hi |
| B | 2014 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2011 | |
| A | 2012 | say hello |
| A | 2013 | he |
| A | 2014 | |
| B | 2010 | |
| B | 2011 | hi, hello! |
| B | 2012 | hi |
| B | 2013 | |
| B | 2014 | hello! |
Files: script.vtl · input/DS_3.csv · input/DS_3.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
Manual example 8 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_4, all)on an annual and a quarterly series of the same phenomenonA.- Manual:
Fill time series, Example 8, output verbatim: “If limitsMethod is all, the time limits are determined with reference to all the time_series of the Data Set: the limits are the minimum and the maximum values of the reference time Identifier Component of the Data Set.”
- Expected:
The limits are the years 2010 to 2012: the annual series gets 2011, and the quarterly one every missing quarter from 2010Q1 to 2012Q4. The manual writes the quarters with a
-, as in2010-Q1, the same periods as2010Q1.
DS_r := fill_time_series ( DS_4, all );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2012 | say hello |
| A | 2010Q1 | he |
| A | 2010Q2 | hi, hello! |
| A | 2010Q4 | hi |
| A | 2011Q2 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010 | hello world |
| A | 2011 | |
| A | 2012 | say hello |
| A | 2010-Q1 | he |
| A | 2010-Q2 | hi, hello! |
| A | 2010-Q3 | |
| A | 2010-Q4 | hi |
| A | 2011-Q1 | |
| A | 2011-Q2 | hello! |
| A | 2011-Q3 | |
| A | 2011-Q4 | |
| A | 2012-Q1 | |
| A | 2012-Q2 | |
| A | 2012-Q3 | |
| A | 2012-Q4 |
Files: script.vtl · input/DS_4.csv · input/DS_4.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
fill_time_series(DS) on date 🟢 · date → date, any type
Default is all 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_1)withoutlimitsMethodon annual date series, as the page’sDS_2, where “conventionally each period is identified by its last day”:Ahas 2010 and 2012,Bthe consecutive 2011 and 2012, which show the annual period in the data.- Manual:
Fill time series:
limitsMethodhas the “default: all”, whose limits “are the minimum and the maximum values of the reference time Identifier Component of the Data Set”, and the operator “is assumed to know which is the reference time Identifier as well as the period of each time series”.- Expected:
The limits are 2010-12-31 and 2012-12-31 for both series, so
Agets 2011-12-31 andBgets 2010-12-31, whichsinglewould not add, each with a nullMe_1.
DS_r := fill_time_series(DS_1);
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | 1 |
| A | 2012-12-31 | 3 |
| B | 2011-12-31 | 5 |
| B | 2012-12-31 | 6 |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | 1 |
| A | 2011-12-31 | |
| A | 2012-12-31 | 3 |
| B | 2010-12-31 | |
| B | 2011-12-31 | 5 |
| B | 2012-12-31 | 6 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
fill_time_series(DS, single) on date 🟢 · date → date, any type
Manual example 3 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_2, single)on annual date series, where “conventionally each period is identified by its last day”.- Manual:
Fill time series, Example 3, output verbatim: “If limitsMethod is single, the time limits are determined with reference to each single time_series of the Data Set: the limits are the minimum and the maximum values of the reference time Identifier Component of the time series.”
- Expected:
Agets 2011-12-31 andBgets 2013-12-31, each with a nullMe_1.
DS_r := fill_time_series ( DS_2, single );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | hello world |
| A | 2012-12-31 | say hello |
| A | 2013-12-31 | he |
| B | 2011-12-31 | hi, hello! |
| B | 2012-12-31 | hi |
| B | 2014-12-31 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | hello world |
| A | 2011-12-31 | |
| A | 2012-12-31 | say hello |
| A | 2013-12-31 | he |
| B | 2011-12-31 | hi, hello! |
| B | 2012-12-31 | hi |
| B | 2013-12-31 | |
| B | 2014-12-31 | hello! |
Files: script.vtl · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
fill_time_series(DS, all) on date 🟢 · date → date, any type
Manual example 4 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_2, all)on annual date series, where “conventionally each period is identified by its last day”.- Manual:
Fill time series, Example 4, output verbatim: “If limitsMethod is all, the time limits are determined with reference to all the time_series of the Data Set: the limits are the minimum and the maximum values of the reference time Identifier Component of the Data Set.”
- Expected:
The limits are 2010-12-31 and 2014-12-31 for both series:
Agets 2011-12-31 and 2014-12-31,Bgets 2010-12-31 and 2013-12-31, each with a nullMe_1.
DS_r := fill_time_series ( DS_2, all );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | hello world |
| A | 2012-12-31 | say hello |
| A | 2013-12-31 | he |
| B | 2011-12-31 | hi, hello! |
| B | 2012-12-31 | hi |
| B | 2014-12-31 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-12-31 | hello world |
| A | 2011-12-31 | |
| A | 2012-12-31 | say hello |
| A | 2013-12-31 | he |
| A | 2014-12-31 | |
| B | 2010-12-31 | |
| B | 2011-12-31 | hi, hello! |
| B | 2012-12-31 | hi |
| B | 2013-12-31 | |
| B | 2014-12-31 | hello! |
Files: script.vtl · input/DS_2.csv · input/DS_2.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
fill_time_series(DS, single) on time 🟢 · time → time, any type
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_1, single)on annual series whose reference time identifier is a time.- Manual:
Fill time series, Example 1: “If limitsMethod is single, the time limits are determined with reference to each single time_series of the Data Set”.
- Expected:
The manual’s output with its time values rewritten:
Agets 2011 andBgets 2013, each the whole yearYYYY-01-01/YYYY-12-31, with a nullMe_1.- Adaptation:
The page writes its time values in “the time format YYYY-MM/YYYY-MM”, as
2010M1/2010M12, which vtlengine cannot load (DataLoadError0-3-1-6, “Use YYYY-MM-DD/YYYY-MM-DD or YYYY or YYYY-MM”, on both engines). EachYYYYM1/YYYYM12of the input and the output is writtenYYYY-01-01/YYYY-12-31, the same interval in theYYYY-MM-DD/YYYY-MM-DDform of the manual’s “Behaviour of Time operators” and ofdocs/data_types.rst; nothing else changes.
DS_r := fill_time_series ( DS_1, single );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-01-01/2010-12-31 | hello world |
| A | 2012-01-01/2012-12-31 | say hello |
| A | 2013-01-01/2013-12-31 | he |
| B | 2011-01-01/2011-12-31 | hi, hello! |
| B | 2012-01-01/2012-12-31 | hi |
| B | 2014-01-01/2014-12-31 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-01-01/2010-12-31 | hello world |
| A | 2011-01-01/2011-12-31 | |
| A | 2012-01-01/2012-12-31 | say hello |
| A | 2013-01-01/2013-12-31 | he |
| B | 2011-01-01/2011-12-31 | hi, hello! |
| B | 2012-01-01/2012-12-31 | hi |
| B | 2013-01-01/2013-12-31 | |
| B | 2014-01-01/2014-12-31 | hello! |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
fill_time_series(DS, all) on time 🟢 · time → time, any type
Manual example 2 🟢 pandas ✅ · DuckDB ✅
- Tests:
fill_time_series(DS_1, all)on annual series whose reference time identifier is a time.- Manual:
Fill time series, Example 2: “If limitsMethod is all, the time limits are determined with reference to all the time_series of the Data Set”.
- Expected:
The manual’s output with its time values rewritten: the limits are 2010 and 2014, so
Agets 2011 and 2014 andBgets 2010 and 2013, each the whole yearYYYY-01-01/YYYY-12-31, with a nullMe_1.- Adaptation:
The page writes its time values in “the time format YYYY-MM/YYYY-MM”, as
2010M1/2010M12, which vtlengine cannot load (DataLoadError0-3-1-6, “Use YYYY-MM-DD/YYYY-MM-DD or YYYY or YYYY-MM”, on both engines). EachYYYYM1/YYYYM12of the input and the output is writtenYYYY-01-01/YYYY-12-31, the same interval in theYYYY-MM-DD/YYYY-MM-DDform of the manual’s “Behaviour of Time operators” and ofdocs/data_types.rst; nothing else changes.
DS_r := fill_time_series ( DS_1, all );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-01-01/2010-12-31 | hello world |
| A | 2012-01-01/2012-12-31 | say hello |
| A | 2013-01-01/2013-12-31 | he |
| B | 2011-01-01/2011-12-31 | hi, hello! |
| B | 2012-01-01/2012-12-31 | hi |
| B | 2014-01-01/2014-12-31 | hello! |
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2010-01-01/2010-12-31 | hello world |
| A | 2011-01-01/2011-12-31 | |
| A | 2012-01-01/2012-12-31 | say hello |
| A | 2013-01-01/2013-12-31 | he |
| A | 2014-01-01/2014-12-31 | |
| B | 2010-01-01/2010-12-31 | |
| B | 2011-01-01/2011-12-31 | hi, hello! |
| B | 2012-01-01/2012-12-31 | hi |
| B | 2013-01-01/2013-12-31 | |
| B | 2014-01-01/2014-12-31 | hello! |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗