[英]How to replace a pattern from a string of values in a column?
我正在嘗試從 Dataframe 列中的值列表中替換模式(“,”)。
final['Type']=final['Type'].replace(",,","")
但是,它不起作用,也沒有替換我的Type
列中的任何值
但是當我嘗試替換特定行時,它正在工作。
例如:
final['Type'][1].replace(",,","")
#this is working and replacing the string
提前致謝!!
嘗試這個:
final['Type'] = final['Type'].str.replace(',,','')
您的代碼僅在值完全匹配時才有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.