9951 explained code solutions for 126 technologies


python-numpyHow to get specific column from Numpy array


import numpy as np
arr = np.array([[1, 2], [3, 4]])
row = arr[:,0]ctrl + c
import numpy as np

load Numpy module for Python

[[1, 2], [3, 4]]

sample matrix data (2-dimensional array)

np.array

declare Numpy array

arr

variable contains array

[:,0]

return first column ('0' index is for first column)