interpolate.linear() function
The interpolate.linear
function inserts rows at regular intervals using
linear interpolation
to determine values for inserted rows.
import "interpolate"
interpolate.linear(every: 1m)
Function requirements
- Input data must have
_time
and_value
columns. _value
column must be of typefloat
.- All columns other than
_time
and_value
must be part of the group key.
Parameters
every
Duration of time between interpolated points.
tables
Input data.
Default is piped-forward data (<-
).
Examples
Interpolate missing data by day
import "interpolate"
data
|> interpolate.linear(every: 1d)
Input
_time | _value |
---|---|
2021-01-01T00:00:00Z | 10.0 |
2021-01-02T00:00:00Z | 20.0 |
2021-01-04T00:00:00Z | 40.0 |
2021-01-05T00:00:00Z | 50.0 |
2021-01-08T00:00:00Z | 80.0 |
2021-01-09T00:00:00Z | 90.0 |
Output
_time | _value |
---|---|
2021-01-01T00:00:00Z | 10.0 |
2021-01-02T00:00:00Z | 20.0 |
2021-01-03T00:00:00Z | 30.0 |
2021-01-04T00:00:00Z | 40.0 |
2021-01-05T00:00:00Z | 50.0 |
2021-01-06T00:00:00Z | 60.0 |
2021-01-07T00:00:00Z | 70.0 |
2021-01-08T00:00:00Z | 80.0 |
2021-01-09T00:00:00Z | 90.0 |
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, the following resources are available:
InfluxDB Cloud customers can contact InfluxData Support.