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.
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]
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.