본문 바로가기

Data handling

[numpy] list of array -> numpy array 변환

반응형

list of array를 np.array로 변환하면 (1000,3)이 될 줄 알았지만 그렇지 않았다.

array shape가 (1000,) 인데

 array[0]을 입력하면 다음과 같이 나온다.

np.vstack 혹은 np.hstack을 해주면 되는데, 

이 경우에는 np.vstack이 맞다.

np.vstack(xyz_values)

 

 

https://stackoverflow.com/questions/21046417/python-conversion-of-list-of-arrays-to-2d-array/32787788

 

Python - Conversion of list of arrays to 2D array

I have a dataset that is formatted like this: A=[(Num1,Num2,Num3), (Num4,Num5,Num6), (Num7,Num8,Num9)] with A.shape = (3,) and I would like to convert this into a 2D numpy array: A=[[Num1,Num2,

stackoverflow.com

 

반응형