Answers for "numpy sum matrix"

5

sum of a numpy array

>>> np.sum([0.5, 1.5])
2.0
>>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)
1
>>> np.sum([[0, 1], [0, 5]])
6
>>> np.sum([[0, 1], [0, 5]], axis=0)
array([0, 6])
>>> np.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])
>>> np.sum([[0, 1], [np.nan, 5]], where=[False, True], axis=1)
array([1., 5.])
Posted by: Guest on October-15-2020
0

python sum whole matrix comand

x = np.matrix([[1, 2], [4, 3]])
>>> x.sum()
Posted by: Guest on January-02-2021

Python Answers by Framework

Browse Popular Code Answers by Language