0
在我的數據框中,我有一個名爲「建議價格」的系列,它有價格,偶爾還會有一個標有「價格已移除」的字符串。我正在嘗試將Price Removed更改爲0.想要將列中的值更改爲0
我不知道如何處理此問題。我嘗試了一個for循環和一個重命名代碼。兩者都沒有給我錯誤,但實際上並沒有將Priced刪除爲0。
有人可以幫我嗎?
我的for循環
for x in analysis['Proposed Price']:
if x == 'Price Removed':
x == 0
else:
analysis['Proposed Price'] = analysis['Proposed Price'].str.replace("$", "").str.replace(",","")
另一個代碼爲:
analysis['Proposed Price'] = analysis['Proposed Price'].rename({'Price Removed' : 0})
我怎樣才能成功改變蜇傷爲0的,所以我終於可以得到所有花車的列?
您應該提供示例輸入。我想當你使用術語數據框時,這意味着你正在使用熊貓,但「分析」的結構不清楚。 – zero323