Fill method transform
The fill_to() transform ensures that there is a point at least every interval, if there is not a point, it fills in the point using the method provided. The timevector must be sorted before calling fill_to(). The available fill methods are:
| fill_method | description |
|---|---|
| LOCF | Last object carried forward, fill with last known value prior to the hole |
| Interpolate | Fill the hole using a collinear point with the first known value on either side |
| Linear | This is an alias for interpolate |
| Nearest | Fill with the matching value from the closer of the points preceding or following the hole |
For example:
sql
SELECT (
toolkit_experimental.timevector(time, value)
-> toolkit_experimental.sort()
-> toolkit_experimental.fill_to('1 day', 'LOCF')
-> toolkit_experimental.unnest()).*
FROM (VALUES (TimestampTZ '2021-01-06 UTC', 0.0 ),
( '2021-01-01 UTC', 25.0 ),
( '2021-01-02 UTC', 0.10),
( '2021-01-04 UTC', -10.0 ),
( '2021-01-05 UTC', 3.3 )
) as v(time, value);The output for this example:
sql
time | value
------------------------+-------
2021-01-01 00:00:00+00 | 25
2021-01-02 00:00:00+00 | 0.1
2021-01-03 00:00:00+00 | 0.1
2021-01-04 00:00:00+00 | -10
2021-01-05 00:00:00+00 | 3.3
2021-01-06 00:00:00+00 | 0
(6 rows)