好的,所以我有一個從CSV文件加載的numpy數(shù)組,該數(shù)組看起來像:array([['0', '3', '22', ..., '7.25', '1', '0'], ['1', '1', '38', ..., '71.2833', '0', '0'], ['1', '3', '26', ..., '7.925', '1', '0'], ..., ['0', '3', '', ..., '23.45', '1', '0'], ['1', '1', '26', ..., '30', '0', '0'], ['0', '3', '32', ..., '7.75', '0', '0']], dtype='|S8')我想將數(shù)組元素轉(zhuǎn)換為浮點型,但出現(xiàn)此錯誤data2 = np.array(data).astype(np.float)Traceback (most recent call last): File "<input>", line 1, in <module>ValueError: could not convert string to float: 有沒有辦法用numpy或pandas解決此問題?
添加回答
舉報
0/150
提交
取消