Adds a moving average to current row with the formula (current_row + previous_N_rows + next_N_rows) / (2 * window_size + 1)
. The first and last N rows are not populated with an average.
Example

Example Input
metric_1 | metric_2 |
1538 | 1258 |
4538 | 4500 |
8351 | 1257 |
2592 | 3850 |
Example Output
metric_1 | metric_2 | New_Average |
1538 | 1258 | |
4538 | 4500 | 2338 |
8351 | 1257 | 3202 |
2592 | 3850 |
I Ain't Afraid of No Code!
[
[
"add_moving_average",
{
"subtable": null,
"field": "metric_2",
"window_size": 1,
"newfield": "New_Average",
"_comment": null
}
]
]
param str subtable: Name a subtable in which output will be stored (will create subtable where necessary).
param str field: Name of the field used as input. Must be converted into numeric type.
param int window_size: Defines N previous and next rows to be considered.
param str newfield: Name of the field holding the moving average.
param str comment: A comment that will appear in the Transformation UI.
Comments
0 comments
Article is closed for comments.