ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

 

[ 문제 ]

 

numpy 로 새로운 array 만들 때 , 

 

numpy.array([[1,2], [1.0, 2.0, 3.0]])

numpy.array([[1,2], [1.0, 2.0, 3.0]], dtype=float)

 

위 처럼 해봤는데 안된다 ...  

 

 

[ 해결 ]
 
dtype=object 로 해주니 해결되었다.

 

numpy.array([[1,2], [1.0, 2.0, 3.0]], dtype=object)

 

 

 

 * 참고

https://stackoverflow.com/questions/4674473/valueerror-setting-an-array-element-with-a-sequence

'! > python' 카테고리의 다른 글

python 문법 가이드  (0) 2025.03.14
python test  (2) 2024.09.26
matplotlib.pyplot 사용하기  (0) 2023.08.08
miniconda 다운로드 (macOS)  (0) 2023.03.08
아나콘다 가상환경 이용하기  (0) 2023.02.23

+ Recent posts