PctChange / Computation Layer
Calculate the percentage change between current and previous values in a numeric column. Similar to pandas.pct_change() or R's diff()/lag() percentage calculations.
Mathematical form: where is the shift amount (ShiftBy
) and is the row index.
Common applications:
- Financial analysis (stock returns, growth rates)
- Economic indicators (GDP growth, inflation rates)
- Sales performance (year-over-year growth)
- Population dynamics (growth rates)
- Market analysis (market share changes)
- Trend analysis (sequential changes)
- Performance metrics (improvement rates)
Note: First n rows (where n is ShiftBy
) will be null. Division by zero results in null values.
Table
0
0
Table
Transforms
[, ...]Select
columnThe numeric column to compute percentage changes for. Typical inputs:
- Price series (stock prices, commodity prices)
- Measurement sequences (sensor readings)
- Performance metrics (sales figures, KPIs)
- Quantity series (inventory levels, counts)
ShiftBy
i64Number of rows to look back for comparison. Common values:
- 1: Adjacent row comparison (default, sequential change)
- 4: Quarter-over-quarter comparison (for quarterly data)
- 12: Year-over-year comparison (for monthly data)
- 52: Year-over-year comparison (for weekly data) Must be positive.
AsColumn
nameName for the new column. If not provided, the system generates a unique name. If AsColumn
matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.