Home > OS >  Changing structure of 2d numpy arrays
Changing structure of 2d numpy arrays

Time:10-20

I have a numpy array named my_array

When I print glove_ds.shape, I get 2049 When I print glove_ds[i].shape, I get 300 (i is within the range of 2049)

I want to change glove_ds shape to 2049*300 (when I call the glove_ds.shape). How should I do that?

So my code is:

print(glove_ds.shape, glove_ds[0].shape)

And the answer is

> (2429,) (300,)

I want the answer to be

(2429*300)

CodePudding user response:

What about my_array.size - it returns the total number of elements in your array https://note.nkmk.me/en/python-numpy-ndarray-ndim-shape-size/, or does it have to be printed as a multiple between 2 numbers? Then my_array.shape and my_array.len can be used

CodePudding user response:

how did you create the Array glove_ds? You should not use "dtype=object". And is the length of every glove_ds[i] the same?

  • Related