Issue
i have a following numpy array.
array([11, 11, 51, 11, 11, 51, 51, 11, 11, 51])
which has a shape (10,)
I want to make it to array([[11], [11], [51], [11], [11], [51], [51], [11], [11], [51]])
and shape should be (10,1)
.
One way to do it using the for loop, but i think which is not good way to get this done.
can someone suggest a more proper way?
thanks
Solution
a = np.array([11, 11, 51, 11, 11, 51, 51, 11, 11, 51])
a = a.reshape(-1,1)
(-1,1)
means that you want the second shape to be exactly 1
and the first shape will be inferred from the length of the array.
Answered By - Salvatore Daniele Bianco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.