I have two 2-D python array lists. I want to on each value in each array perform an operation on each other and append that value into a list while retaining the 2-D structure.
For example I have
list1 = [[1,2,3],[4,5,6],[7,8,9]]
list2 = [[3,2,1],[6,5,4],[9,8,7]]
I want to do so that (for example just simple addition) the output is
output_list: [[4,4,4],[10,10,10],[16,16,16]]
In my case, I am calculating the standard deviation.
I have two 2-D lists named rolling_mean and mean_std that I am doing parallel iteration over and appending to an list named lower_bound
lower_bound = []
for k,h in zip(range(len(rolling_mean)),range(len(mean_std))):
for l,m in zip(range(len(rolling_mean[k])),range(len(mean_std[h]))):
lower_bound.append(rolling_mean[k][l] - (1.96 * mean_std[h][m]))
print(lower_bound)
This is giving me the correct output but the values are all in one single array. I want it to be a 2-D array like the example output above.
>Solution :
...
lb_part = []
for l,m ...
lb_part.append(...)
lower_bound.append(lb_part)