Practice for numpy arrays

try to create the following numpy arrays

  1. a 3x3 numpy array that’s like an identity matrix (1 as the element in the diagonal).
  2. a 1d array containing just nan values. (length as you prefer)
  3. a 2D array with just 1 as values

also, checkout np.where, np.select and np.vectorize. very useful.

2 Likes