dataFrame.columns.stat — percentChange()
Description
The percentChange() method of the stat object computes the percentage change between two selected columns for each row.
Signature
dataFrame.columns(...columnNames).stat.percentChange()Argument
...columnNames( string[] )- The name of the columns from which to compute the percentage change.
Returns
mask( number[] )- The percentage change computed for each row.
Notes
- The method requires exactly two selected columns.
- The first selected column is interpreted as the reference value.
- The second selected column is interpreted as the comparison value.
- Percentage change is computed relative to the first selected column.
- Positive values indicate an increase.
- Negative values indicate a decrease.
- A value of
0indicates no change.
Example
// evaluates the percent change betwwen values of 2 columns of the dataFrame
var mask = dataFrame.columns('revenue_2024', 'revenue_2024').stat.percentChange();
// add the percent changes into the dataFrame
dataFrame.column('percentChange').set(mask);