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, 2019 in Python by Ritu
835 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, 2019 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
579 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
576 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,560 points
1,311 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to save numpy array?

Hi@akhtar, You can use numpy.save() function to save ...READ MORE

answered Jun 22, 2020 in Python by MD
• 95,440 points
1,565 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,300 points
519 views
0 votes
1 answer

how to manage memory in python?

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

answered May 21, 2019 in Python by Mohammad
• 3,230 points
626 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP