Doubt in numpy.vstack

0 votes

I wanted to ask that the following code doesn't work

c=vstack(tsne_data,label_1000).T

where shape of tsne_data is (1000,2) and the shape of label_1000 is (1000,)

but the following code works for the same

c=vstack(tsne_data.T,label_1000).T

for the same shape of tsne_data and label_1000

so I wanted to know that why do we need to use transpose with tsne_data in vstack

Jul 30 in Python by Ritu
63 views

1 answer to this question.

0 votes

The vstack function in numpy will stack the sequence vertically (row wise).

If you see the below example shape of the row in a and b are not similar so you won't be able to add b to a.image

In order to do that you will have to find the transpose of it so that shape of rows in a and b are similar

image

answered Jul 30 by Esha

Related Questions In Python

0 votes
1 answer

Numpy data in csv

Use this -  numpy.savetxt("data.csv", arr, delimiter=",") READ MORE

answered Jul 3, 2018 in Python by Hamartia's Mask
• 1,580 points
45 views
0 votes
1 answer

Mean and average in numpy

np.average() can be used to calculate weighted ...READ MORE

answered Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
64 views
0 votes
1 answer

In NumPy how do I get the maximum of subsets? Python

You can use np.maximum.reduceat: >>> _, idx = np.unique(g, ...READ MORE

answered Nov 9, 2018 in Python by Nymeria
• 3,520 points
86 views
0 votes
1 answer

How to save Numpy array as image in python?

If you have matplotlib, you can do: import ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,520 points
2,718 views
+1 vote
2 answers

View onto a numpy array?

 just index it as you normally would. ...READ MORE

answered Oct 18, 2018 in Python by roberto
59 views
0 votes
1 answer

Is there a string 'contains' in python?

In this case, you can use the ...READ MORE

answered Sep 25, 2018 in Python by SDeb
• 13,210 points
71 views
0 votes
1 answer

how to manage memory in python?

Memory management in python involves a private heap ...READ MORE

answered May 20 in Python by Mohammad
• 3,170 points
23 views