TypeError: cannot convert the series to <class ‘float‘>问题解决
生活随笔
收集整理的這篇文章主要介紹了
TypeError: cannot convert the series to <class ‘float‘>问题解决
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
原來的出錯(cuò)代碼是這樣的
getDistance(p[3][0],p[3][1],L[j]['lat'],L[j]['lng'])報(bào)錯(cuò):
TypeError: cannot convert the series to <class 'float'>我的解決辦法是
for i in range(len(L)):for j in range(len(L[i])):lat=L[i]['lat'][j]lng=L[i]['lng'][j]d1=getDistance(p[0][0],p[0][1],lat,lng)此時(shí)運(yùn)行出來了。
之前嘗試過
(1)astype()轉(zhuǎn)為float (2)使用pd.to_numeric與errors='coerce' (3)利用apply的形式統(tǒng)統(tǒng)都沒有解決。
感謝:
https://stackoverflow.com/questions/49668387/type-error-cannot-convert-the-series-to-class-float提供最終解題靈感。
總結(jié)
以上是生活随笔為你收集整理的TypeError: cannot convert the series to <class ‘float‘>问题解决的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MATLAB移植C的小结
- 下一篇: 机器学习笔记六之神经网络的学习