port interpolate pkg from flux-restructure branch, closes #2414 (#2467)

pull/2468/head
Scott Anderson 2021-04-30 13:21:17 -06:00 committed by GitHub
parent 433421634a
commit 48449a92ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 124 additions and 0 deletions

View File

@ -0,0 +1,15 @@
---
title: Flux interpolate package
list_title: Interpolate package
description: >
The Flux `interpolate` package provides functions that insert rows for missing
data at regular intervals and estimate values using different interpolation methods.
Import the `interpolate` package.
menu:
influxdb_cloud_ref:
name: Interpolate
parent: Flux standard library
weight: 202
---
{{< duplicate-oss >}}

View File

@ -0,0 +1,15 @@
---
title: interpolate.linear() function
description: >
The `interpolate.linear` function inserts rows at regular intervals using
**linear interpolation** to determine values for inserted rows.
menu:
influxdb_cloud_ref:
name: interpolate.linear
parent: Interpolate
weight: 301
introduced: 0.87.0
list_query_example: interpolate_linear
---
{{< duplicate-oss >}}

View File

@ -0,0 +1,23 @@
---
title: Flux interpolate package
list_title: Interpolate package
description: >
The Flux `interpolate` package provides functions that insert rows for missing
data at regular intervals and estimate values using different interpolation methods.
Import the `interpolate` package.
menu:
influxdb_2_0_ref:
name: Interpolate
parent: Flux standard library
weight: 202
---
The `interpolate` package provides functions that insert rows for missing
data at regular intervals and estimate values using different interpolation methods.
Import the `interpolate` package:
```js
import "interpolate"
```
{{< children type="articles" show="pages" >}}

View File

@ -0,0 +1,71 @@
---
title: interpolate.linear() function
description: >
The `interpolate.linear` function inserts rows at regular intervals using
**linear interpolation** to determine values for inserted rows.
menu:
influxdb_2_0_ref:
name: interpolate.linear
parent: Interpolate
weight: 301
introduced: 0.87.0
list_query_example: interpolate_linear
---
The `interpolate.linear` function inserts rows at regular intervals using
[linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
to determine values for inserted rows.
```js
import "interpolate"
interpolate.linear(every: 1m)
```
#### Function requirements
- Input data must have `_time` and `_value` columns.
- **All columns** other than `_time` and `_value` must be part of the group key.
## Parameters
### every
Duration of time between interpolated points.
_**Data type:** Duration_
## Examples
### Interpolate missing data by day
```js
import "interpolate"
data
|> interpolate.linear(every: 1d)
```
{{< flex >}}
{{% flex-content %}}
##### 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 |
{{% /flex-content %}}
{{% flex-content %}}
##### Output
| _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-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 |
{{% /flex-content %}}
{{< /flex >}}