2021-01-29
閱讀量:
1455
Python報(bào)錯(cuò):AttributeError: 'float' object has no attribute 'lower'
問:
Python報(bào)錯(cuò):AttributeError: 'float' object has no attribute 'lower'
答:
出現(xiàn)以上報(bào)錯(cuò)是因?yàn)閿?shù)據(jù)中存在的缺失值np.nan屬于float類型,float型數(shù)據(jù)不支持lower()方法,
所以會報(bào)'float' object has no attribute 'lower'錯(cuò)誤,可以通過Pandas的str屬性解決此問題,
使用str屬性會自動排除缺失值,代碼如下:






評論(0)


暫無數(shù)據(jù)
CDA考試動態(tài)
CDA報(bào)考指南
推薦帖子
0條評論
0條評論
0條評論
0條評論