numpy create 2d array code example
Example 1: numpy generate random 2d array
import numpy as np
a=np.random.rand(3,3)
print(a)
Example 2: how to create multidimensional array in python using numpy
from numpy import *
array = array([[1,2,3,4],[3,4,2,5]])
## if want you can print it
print(array)
Example 3: create a 2d array in python
def build_matrix(rows, cols):
matrix = []
for r in range(0, rows):
matrix.append([0 for c in range(0, cols)])
return matrix
if __name__ == '__main__':
build_matrix(6, 10)
Example 4: numpy array get a value from a 2D array
arrayName[rowNumber, columnNumber]