Calculating Averages in Data Trees Without Using Explode Component

Hello everyone,

I am trying to perform calculations within a data tree without using the explode component, as I want it to be flexible depending on the lengths of each branch in the tree.
Specifically, I want to calculate the average of each row while keeping the main trees separate from each other. I am finding it difficult to perform even simpler operations, such as additions, due to the structure of these trees.

Any advice would be greatly appreciated.

Thank you,
Matteo

Which “explode” component were you using?

Did you use the ‘average’ component?

LoL - sorry, silly questions - how about you post a file for someone to help? :slight_smile:

1 Like

Hi @René_Corella

I haven’t used the “Explode Tree” because I wanted it to be flexible.

The “Average” component doesn’t work because it averages the n values inside each list, not the rows of each tree. If it were a simple data structure (e.g., {0;0}, {0;1}, {0;2}, {0;3},…) I could have used “Flip Matrix” > “Average” > “Flip Matrix” again, but I have complex data structure (e.g., {0;0}, {0;1}, {1;0}, {1;1},…) and “Flip Matrix” doesn’t work.

However, here’s the solution I found: using the “Path Mapper” component ({A;B} to {A}) and a python script to compute the average, that works with lists whose length is a multiple of the specified interval (8760 in my case).

Here’s the script if anyone needs it in the future:

interval = 8760
result = [0] * interval
for i in range(len(data)):
    result[i % interval] += data[i]
divisor = len(data) // interval
result = [x / divisor for x in result]

1 Like

A colleague of mine has found a more effective and clean way to solve the problem. Here it is:

I think it is nice that you found a solution, but I would raise more attention on how to get help here. If you provide an example, so that people do not need to recreate the same problem first, then this makes it easier for anyone to help. Other than that, I found it difficult to follow your explanation. It really helps to pay more attention to explain the problem as easy as possible and to give a simple example everyone can follow. You could have shared an example with the explode component for instance.