0

how can complete this ndarray (matrix):

np.array([[2,2], [2]])

to be a matrix, with zeroes in the missing values:

np.array([[2,2], [2,0]])

thanks.

Ilan12
  • 81
  • 2
  • 11
  • Check out numpy.pad() function. It seems like a solution for you. Also take a look at this post https://stackoverflow.com/questions/35751306/python-how-to-pad-numpy-array-with-zeros – Meto May 09 '20 at 16:08
  • Does this answer your question? [python how to pad numpy array with zeros](https://stackoverflow.com/questions/35751306/python-how-to-pad-numpy-array-with-zeros) – izhang05 May 09 '20 at 16:11
  • This is not a padding problem @izhang05 padding works well with homogeneous arrays, and serves another purpose – yatu May 09 '20 at 16:19
  • padding doesn't work, the problem is that it also create a np array of lists. – Ilan12 May 10 '20 at 18:18

0 Answers0