9951 explained code solutions for 126 technologies


python-numpyHow to get specific row from Numpy array


import numpy as np
arr = np.array([[1, 2], [3, 4]])
row = arr[1,:]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

[1,:]

return second row (index number is 1) of the specified matrix