I would like to store intermediate results from a nested list comprehension in sublists so that the result looks like this:
example_list = [[[1,2,3], [1,2,3]], [[2,3,4], [2,3,4]]];
sink = [];
for sl in example_list :
temp = [];
for ssl in sl :
temp.append(np.mean(ssl));
sink.append(temp);
expected_result = [[2,2], [3,3]];
How do you perform this using a list comprehension?
I tried something like this, but obviously it doesn't work, I'm blocked on the syntax:
sink = [[np.mean(j)] for i in example_list for j in i];