derivative() function
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
- Calculate the non-negative rate of change per second
- Calculate the rate of change per second with null values
Calculate the rate of change per second
import "sampledata"
sampledata.int()
|> derivative()
Calculate the non-negative rate of change per second
import "sampledata"
sampledata.int()
|> derivative(nonNegative: true)
Calculate the rate of change per second with null values
import "sampledata"
sampledata.int(includeNull: true)
|> derivative()
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.