Consider the following code:
arr = np.array([[1, 2, 3],[2, 3, 3]])
list1 = arr.tolist()
print(list1)
[[1, 2, 3], [2, 3, 3]]
I want to create a sum of the entire content to get the following output
list_sum=[[3, 5, 6]]
Is there an elegant way to quickly do this?
CodePudding user response:
You can just use numpy's native summing with an axis:
In [39]: arr.sum(axis=0)
Out[39]: array([3, 5, 6])
