Feb-08-2018, 11:18 AM
With numpy:
import numpy as np shape = (2,5) arr1 = np.zeros(shape) print(arr1)With stock Python:
shape = (2,5) arr2 = [] fill_value = 0 for a in range(shape[0]): row = [] for b in range(shape[1]): row.append(fill_value) arr2.append(row) print(arr2)Accessing multi dimensional lists with stock Python:
arr2[0][1] arr2[0][0:2]Same with numpy:
arr1[0,1] arr1[0,0:2]More complex stuff with numpy:
arr1[:,::2]Returns all rows, from each row the even fields are selected.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!