I have a numpy arrayx = np.array([145100, [ 1,2,3 ], 100.6])
and I wish to ravel it to this:[145100, 1,2,3 , 100.6]
I tried this, but it didn't gave any results:
x = np.ravel(x)
As the shape was still (3,) instead of (5,). What am I missing?
Best Answer
Use numpy.hstack
:
import numpy as npx = np.array([145100, [ 1,2,3 ], 100.6])x = np.hstack(x)
array([1.451e+05, 1.000e+00, 2.000e+00, 3.000e+00, 1.006e+02])