Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Array shape in python

Tags:

python

numpy

This is going to be a rather silly question, though it is annoying. I have a list of 800 ndarrays which have 7680 elements each. How do I get this to a <800,7680> format ?

enter image description here

like image 741
Olivier_s_j Avatar asked Feb 04 '26 18:02

Olivier_s_j


1 Answers

Just pass it to the np.array factory function. As an example:

>>> lst = [np.zeros(7680) for x in range(800)]  #just a list of 800 ndarrays ...
>>> arr = np.array(lst)   #make them into an array
>>> arr.shape   #shape looks OK to me :-)
(800, 7680)
like image 62
mgilson Avatar answered Feb 07 '26 09:02

mgilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!