NumPy axis

How to calculate an ndarray array by specifying axis Calculate in column direction with 0 Calculate in the row direction with 1

python


import numpy as np

arr = np.array([[1, 2 ,3], [4, 5, 6]])

print(arr.sum())
print(arr.sum(axis=0))
print(arr.sum(axis=1))

python


>>>Output result
21
[5 7 9]
[ 6 15]

Recommended Posts

NumPy axis
Axis specification in NumPy
numpy practice 1
Numpy [Basic]
numpy part 1
NumPy basics
Numpy Memorandum_Matrix
About axis = 0, axis = 1
numpy tips
About numpy
Use Numpy
numpy part 2
My Numpy (Python)
where in numpy
numpy unit test
list and numpy
NumPy universal functions
numpy memorandum 1 / np.pad
Understand numpy's axis
#Python basics (#Numpy 1/2)
#Python basics (#Numpy 2/2)
numpy index search
NumPy array manipulation (1)
[Numpy] Shuffle ndarray
Python #Numpy basics
numpy non-basic techniques
About Numpy broadcast
[PyTorch] Sample ① ~ NUMPY ~
Install Numpy + atlas
[Python] Numpy memo