팬더 시리즈를 dtype = float64의 NumPy 배열로 변환해야합니다. 이것은 오류를 발생시키는 코드입니다.
series = pd.Series( [np.random.randn(5), np.random.randn(5), np.random.randn(5), np.random.randn(5)])
res = series.to_numpy()
res.astype(np.float64)
이것은 내가 얻은 오류입니다.
----> 3 res.astype(np.float64)
ValueError: setting an array element with a sequence.
이것이 오류가 발생하는 이유를 이해하고이를 수정하는 방법이 있습니까?
단일 부동으로 변환 할 수없는 일련의 목록이 있습니다. 시험:
res = np.array(series.to_list(), dtype=np.float64)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다