customerDF[['TotalCharges']].astype(np.float64)
出錯:could not convert string to float
customerDF['TotalCharges']=customerDF['TotalCharges'].convert_objects(convert_numeric=True)
出錯:'Series' object has no attribute 'convert_objects'
其中customerDF為dataframe型別
customerDF['TotalCharges']為series型別
請問怎么寫才對呢
uj5u.com熱心網友回復:
確定轉化那一列全是純數字 沒有什么字母 符號之類的嘛uj5u.com熱心網友回復:
有的是有空值
uj5u.com熱心網友回復:
如果沒有字母和符號,只有空值的話,那你就得對空值進行特殊處理了,比如判斷出是空值,則設定為0。然后基數的數字串正常轉換就應該沒問題了!
uj5u.com熱心網友回復:
然后基數的數字串正常轉換就應該沒問題了!改為:
然后其它的數字串正常轉換就應該沒問題了!
uj5u.com熱心網友回復:
然后基數的數字串正常轉換就應該沒問題了!
改為:
然后其它的數字串正常轉換就應該沒問題了!
好的謝謝你啦
uj5u.com熱心網友回復:
有判斷填充的陳述句,可以一下子填充完畢。轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/78158.html
上一篇:python新手問題pip
下一篇:python
