1
我想使用熊貓將列的類型轉換爲int。這裏的源代碼:如何避免熊貓中的SettingWithCopyWarning?
# CustomerID is missing on several rows. Drop these rows and encode customer IDs as Integers.
cleaned_data = retail_data.loc[pd.isnull(retail_data.CustomerID) == False]
cleaned_data['CustomerID'] = cleaned_data.CustomerID.astype(int)
這就提出瞭如下警告:
SettingWithCopyWarning:值是試圖從一個數據幀上 片的副本設置
如何我可以避免這種警告嗎?有沒有更好的方式將CustomerID的類型轉換爲int?我在python 3.5上。
可能重複:http://stackoverflow.com/q/38809796/190597 – unutbu