Documentation

derivative() function

Flux 0.7.0+

The derivative() function computes the rate of change per unit of time between subsequent non-null records. It assumes rows are ordered by the _time column. The output table schema is the same as the input table.

Output data type: Float

derivative(
  unit: 1s,
  nonNegative: true,
  columns: ["_value"],
  timeColumn: "_time"
)

Parameters

unit

The time duration used when creating the derivative. Default is 1s.

nonNegative

Indicates if the derivative is allowed to be negative. Default is true. When true, if a value is less than the previous value, it is assumed the previous value should have been a zero.

columns

The columns to use to compute the derivative. Default is ["_value"].

timeColumn

The column containing time values. Default is "_time".

tables

Input data. Default is piped-forward data (<-).

Output tables

For each input table with n rows, derivative() outputs a table with n - 1 rows.

Examples

The following examples use data provided by the sampledata package to show how derivative() transforms data.

Calculate the rate of change per second

import "sampledata"

sampledata.int()
  |> derivative()

View input and output

Calculate the non-negative rate of change per second

import "sampledata"

sampledata.int()
  |> derivative(nonNegative: true)

View input and output

Calculate the rate of change per second with null values

import "sampledata"

sampledata.int(includeNull: true)
  |> derivative()

View input and output


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.