簡體   English   中英

AttributeError:'NoneType'對象在python中沒有屬性'lower'

[英]AttributeError: 'NoneType' object has no attribute 'lower' in python

我試圖從給定的地址預測地點。 我已經使用python保存了模型和加載

locality_address= df_fatch_ID_Address['Col_1_add'].values.tolist()

print (locality_address)

打印locality_address得到類型地址但運行result_locality得到錯誤。

輸入數據:

Kastur Park
Green Homes, Kanti Nagar
Tata Shubh Griha, Vasind

我收到錯誤AttributeError: 'NoneType' object has no attribute 'lower'在運行下面之后AttributeError: 'NoneType' object has no attribute 'lower'

result_locality = model_locality.predict(locality_address)
print (result_locality)      

並非locality_address中的所有數據都是str類型。
這意味着model_locality.predict(locality_address)正在對數據調用str.lower()函數並失敗,因為某些數據為None
要解決此問題,您必須清理數據集以確保將None更改為''或您的model_locality.predict()可以使用的其他值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM