docs-v2/content/flux/v0.x/stdlib/interpolate/linear.md

2.7 KiB

title description menu weight flux/v0.x/tags
interpolate.linear() function `interpolate.linear()` inserts rows at regular intervals using linear interpolation to determine values for inserted rows.
flux_0_x_ref
name parent identifier
interpolate.linear interpolate interpolate/linear
101
transformations

interpolate.linear() inserts rows at regular intervals using linear interpolation to determine values for inserted rows.

Function requirements

  • Input data must have _time and _value columns.
  • All columns other than _time and _value must be part of the group key.
Function type signature
(<-tables: stream[{A with _value: float, _time: time}], every: duration) => stream[{A with _value: float, _time: time}]

{{% caption %}}For more information, see Function type signatures.{{% /caption %}}

Parameters

every

({{< req >}}) 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)

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time _value
2021-01-01T00:00:00Z 10
2021-01-02T00:00:00Z 20
2021-01-04T00:00:00Z 40
2021-01-05T00:00:00Z 50
2021-01-08T00:00:00Z 80
2021-01-09T00:00:00Z 90

Output data

_time _value
2021-01-01T00:00:00Z 10
2021-01-02T00:00:00Z 20
2021-01-03T00:00:00Z 30
2021-01-04T00:00:00Z 40
2021-01-05T00:00:00Z 50
2021-01-06T00:00:00Z 60
2021-01-07T00:00:00Z 70
2021-01-08T00:00:00Z 80
2021-01-09T00:00:00Z 90

{{% /expand %}} {{< /expand-wrapper >}}