9951 explained code solutions for 126 technologies


python-numpyHow to get first row 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 row (index number is 0) of the specified matrix