我有一個包含幾百列的熊貓資料框。許多這些列以“($)”結尾[實際代碼中沒有顯示引號]。
我使用了以下內容,但隨后無法應用于我的專欄
# Remove ($)
for i in WholeLoan_df.columns:
re.sub("[($)]","",i)
任何幫助表示贊賞。
謝謝,
uj5u.com熱心網友回復:
而不是使用回圈,使用rstrip:
df.columns = df.columns.str.rstrip(r' ($)'
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/398894.html
上一篇:R在預定義位置拆分字串
