Md. Zakir Hossan
Md. Zakir Hossan

Reputation: 537

How to sum a multidimensional array?

Let A = np.ones([3,3,5]).

Is there any linear algebra operation which will return array([[ 9., 9., 9., 9., 9.]]) without any looping?

Upvotes: 0

Views: 395

Answers (1)

user2357112
user2357112

Reputation: 282026

A.sum(axis=(0, 1))

Call the standard sum routine with a tuple of axes to sum over.

Upvotes: 2

Related Questions