2021年3月13日星期六

Creating a matrix from an array using numpy

I have a(n,) numpy array Y that has integers. Y = [1 1 2 0 .....].T I have to create a matrix (k, n) such that each column has 1 at the index position Y[i] and 0 elsewhere. I don't want to use loops. Can somebody help?

https://stackoverflow.com/questions/66620993/creating-a-matrix-from-an-array-using-numpy March 14, 2021 at 12:06PM

没有评论:

发表评论