作者Ryan45758 (陈启详)
看板Python
标题[问题] python型别转换
时间Sun Jun 14 16:38:15 2020
大家好,我想把train_X里的资料全部统一成float,但试了很久依旧跑出ValueError: could not convert string to float: 'X',不太懂问题出在哪。
http://i.imgur.com/ndjNC8M.png
用了astype也一样
http://i.imgur.com/Dxx1KsU.png
对了,train_X是ndarray
http://i.imgur.com/4sb4zCd.png
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 110.50.175.10 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1592123899.A.CDC.html
1F:推 TuCH: 阿就资料有个栏位是'X' 没办法转float 检查一下资料吧 06/14 16:57
好 感谢
※ 编辑: Ryan45758 (110.50.175.10 台湾), 06/14/2020 17:06:22
2F:→ Pieteacher: mixed type 06/14 18:19
3F:→ stlevi811101: python报错已经很友善了 可能要试着学看ValueError 06/14 23:57
4F:→ mychiux413: 同意楼上,python报错算很清楚了,仔细看都能解掉 06/15 14:18