Fill time series · fill_time_series

🟢 8 of 8 forms all ok · VTL 2.2 Reference Manual ↗ · vtlengine 1.10.0rc3 (9e1c81a6) · pandas 2.3.3 · DuckDB 1.5.5
🟢 all ok🟡 partially implemented🛡️ refused with an error🔴 not implemented or crash🔵 engines differ ✅ match · ❌ wrong result · 🛡 guarded error (code) · 💥 crash · 📌 team decision
        ---
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

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
Definitions (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) without limitsMethod on annual time_period series: A has 2010 and 2012, B has 2011 and 2012.

Manual:

Fill time series: limitsMethod has 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 A gets 2011 and B gets 2010, which single would not add; “For the added Data Points, Measures and Attributes assume the null value.”

script.vtl
DS_r := fill_time_series(DS_1);
Input DS_1
Id_1Id_2Me_1
A20101
A20123
B20115
B20126
Expected DS_r
Id_1Id_2Me_1
A20101
A2011
A20123
B2010
B20115
B20126

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 and B, from 2011 to 2014, gets 2013, each with a null Me_1; nothing is added outside the limits of its series.

script.vtl
DS_r := fill_time_series ( DS_3, single );
Input DS_3
Id_1Id_2Me_1
A2010hello world
A2012say hello
A2013he
B2011hi, hello!
B2012hi
B2014hello!
Expected DS_r
Id_1Id_2Me_1
A2010hello world
A2011
A2012say hello
A2013he
B2011hi, hello!
B2012hi
B2013
B2014hello!

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 phenomenon A, 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.

script.vtl
DS_r := fill_time_series ( DS_4, single );
Input DS_4
Id_1Id_2Me_1
A2010hello world
A2012say hello
A2010Q1he
A2010Q2hi, hello!
A2010Q4hi
A2011Q2hello!
Expected DS_r
Id_1Id_2Me_1
A2010hello world
A2011
A2012say hello
A2010Q1he
A2010Q2hi, hello!
A2010Q3
A2010Q4hi
A2011Q1
A2011Q2hello!

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: A gets 2011 and 2014, B gets 2010 and 2013, each with a null Me_1.

script.vtl
DS_r := fill_time_series ( DS_3, all );
Input DS_3
Id_1Id_2Me_1
A2010hello world
A2012say hello
A2013he
B2011hi, hello!
B2012hi
B2014hello!
Expected DS_r
Id_1Id_2Me_1
A2010hello world
A2011
A2012say hello
A2013he
A2014
B2010
B2011hi, hello!
B2012hi
B2013
B2014hello!

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 phenomenon A.

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 in 2010-Q1, the same periods as 2010Q1.

script.vtl
DS_r := fill_time_series ( DS_4, all );
Input DS_4
Id_1Id_2Me_1
A2010hello world
A2012say hello
A2010Q1he
A2010Q2hi, hello!
A2010Q4hi
A2011Q2hello!
Expected DS_r
Id_1Id_2Me_1
A2010hello world
A2011
A2012say hello
A2010-Q1he
A2010-Q2hi, hello!
A2010-Q3
A2010-Q4hi
A2011-Q1
A2011-Q2hello!
A2011-Q3
A2011-Q4
A2012-Q1
A2012-Q2
A2012-Q3
A2012-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) without limitsMethod on annual date series, as the page’s DS_2, where “conventionally each period is identified by its last day”: A has 2010 and 2012, B the consecutive 2011 and 2012, which show the annual period in the data.

Manual:

Fill time series: limitsMethod has 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 A gets 2011-12-31 and B gets 2010-12-31, which single would not add, each with a null Me_1.

script.vtl
DS_r := fill_time_series(DS_1);
Input DS_1
Id_1Id_2Me_1
A2010-12-311
A2012-12-313
B2011-12-315
B2012-12-316
Expected DS_r
Id_1Id_2Me_1
A2010-12-311
A2011-12-31
A2012-12-313
B2010-12-31
B2011-12-315
B2012-12-316

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:

A gets 2011-12-31 and B gets 2013-12-31, each with a null Me_1.

script.vtl
DS_r := fill_time_series ( DS_2, single );
Input DS_2
Id_1Id_2Me_1
A2010-12-31hello world
A2012-12-31say hello
A2013-12-31he
B2011-12-31hi, hello!
B2012-12-31hi
B2014-12-31hello!
Expected DS_r
Id_1Id_2Me_1
A2010-12-31hello world
A2011-12-31
A2012-12-31say hello
A2013-12-31he
B2011-12-31hi, hello!
B2012-12-31hi
B2013-12-31
B2014-12-31hello!

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: A gets 2011-12-31 and 2014-12-31, B gets 2010-12-31 and 2013-12-31, each with a null Me_1.

script.vtl
DS_r := fill_time_series ( DS_2, all );
Input DS_2
Id_1Id_2Me_1
A2010-12-31hello world
A2012-12-31say hello
A2013-12-31he
B2011-12-31hi, hello!
B2012-12-31hi
B2014-12-31hello!
Expected DS_r
Id_1Id_2Me_1
A2010-12-31hello world
A2011-12-31
A2012-12-31say hello
A2013-12-31he
A2014-12-31
B2010-12-31
B2011-12-31hi, hello!
B2012-12-31hi
B2013-12-31
B2014-12-31hello!

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: A gets 2011 and B gets 2013, each the whole year YYYY-01-01/YYYY-12-31, with a null Me_1.

Adaptation:

The page writes its time values in “the time format YYYY-MM/YYYY-MM”, as 2010M1/2010M12, which vtlengine cannot load (DataLoadError 0-3-1-6, “Use YYYY-MM-DD/YYYY-MM-DD or YYYY or YYYY-MM”, on both engines). Each YYYYM1/YYYYM12 of the input and the output is written YYYY-01-01/YYYY-12-31, the same interval in the YYYY-MM-DD/YYYY-MM-DD form of the manual’s “Behaviour of Time operators” and of docs/data_types.rst; nothing else changes.

script.vtl
DS_r := fill_time_series ( DS_1, single );
Input DS_1
Id_1Id_2Me_1
A2010-01-01/2010-12-31hello world
A2012-01-01/2012-12-31say hello
A2013-01-01/2013-12-31he
B2011-01-01/2011-12-31hi, hello!
B2012-01-01/2012-12-31hi
B2014-01-01/2014-12-31hello!
Expected DS_r
Id_1Id_2Me_1
A2010-01-01/2010-12-31hello world
A2011-01-01/2011-12-31
A2012-01-01/2012-12-31say hello
A2013-01-01/2013-12-31he
B2011-01-01/2011-12-31hi, hello!
B2012-01-01/2012-12-31hi
B2013-01-01/2013-12-31
B2014-01-01/2014-12-31hello!

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 A gets 2011 and 2014 and B gets 2010 and 2013, each the whole year YYYY-01-01/YYYY-12-31, with a null Me_1.

Adaptation:

The page writes its time values in “the time format YYYY-MM/YYYY-MM”, as 2010M1/2010M12, which vtlengine cannot load (DataLoadError 0-3-1-6, “Use YYYY-MM-DD/YYYY-MM-DD or YYYY or YYYY-MM”, on both engines). Each YYYYM1/YYYYM12 of the input and the output is written YYYY-01-01/YYYY-12-31, the same interval in the YYYY-MM-DD/YYYY-MM-DD form of the manual’s “Behaviour of Time operators” and of docs/data_types.rst; nothing else changes.

script.vtl
DS_r := fill_time_series ( DS_1, all );
Input DS_1
Id_1Id_2Me_1
A2010-01-01/2010-12-31hello world
A2012-01-01/2012-12-31say hello
A2013-01-01/2013-12-31he
B2011-01-01/2011-12-31hi, hello!
B2012-01-01/2012-12-31hi
B2014-01-01/2014-12-31hello!
Expected DS_r
Id_1Id_2Me_1
A2010-01-01/2010-12-31hello world
A2011-01-01/2011-12-31
A2012-01-01/2012-12-31say hello
A2013-01-01/2013-12-31he
A2014-01-01/2014-12-31
B2010-01-01/2010-12-31
B2011-01-01/2011-12-31hi, hello!
B2012-01-01/2012-12-31hi
B2013-01-01/2013-12-31
B2014-01-01/2014-12-31hello!

Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗