for example, I have a series of data in time stamp. I want to average the features every 5 rows. any node in Knime with such function?

Hi @HY_Z

Do you mean Rolling Average?

You can do it with a āMoving Aggregationā node. Defining a āforwardā window length == 5 in your case, and using Mean as aggregator for the column valueā¦

These are the basicsā¦

BR

Hi @HY_Z

Like @gonhaddock mentions, what do you consider every 5 rows.

If you are meaning the average for batches of 5 rows, you can use a **Chunk Loop** for this with Rows per Chunk set to 5.

Within the loop, calculate the average with a node of choice. With a Cross Joiner you link the rows within the chunk with the average. After all chunks have been processed, the loop will output the full data set again.

For illustration purposes, Iām just using a bunch of sequential integers.

WF:

How To Average Every 5 Rows In Knime.knwf (27.6 KB)

Hope this helps!

thanks for reply.

When applying rolling average, every step one row is moved down, and the new average is calculated accordingly.

What I want to do is just get average for every 5 rows. If I have 100 rows, then finally 20 points will be got.

Thanks a lot. I will try this way.

Hi @HY_Z

Then you can consider to indexing the rolling average in groups of 5 with a Math Formula node:

`mod($$ROWINDEX$$, 5)`

And afterwards filter out any desired index, or a Rule Engine to BLANK() the unwanted for the whole series.

BR

Thanks a lot. How to āindexing the rolling average in groups of 5 wit a Math Formula nodeā?

There is a moving average node. Have you tried it?

br

You can try a Window Loop Node, as it will allow to configure how many rows should be considered per loop. You can define the window size (5) and need to select also the step size (5) to achieve your desired result.

Thanks. I ever try āMoving average Nodeā. Its function is to calculate the average for Row1 to Row5, then Row2 to Row6, then Row3 to Row7ā¦

it is different from my requirement.

Thank you. Will try this.

That is interesting because I do not see any operation within the window. Math formula with the column mean inside the window could also work

But glad that you found a solution which works for you

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.