!/python
[Error] ValueError: setting an array element with a sequence
miya
2023. 8. 8. 18:44
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