我有以下的數據幀大熊貓:用另一個字符串替換字符串
prod_type
0 responsive
1 responsive
2 respon
3 r
4 respon
5 r
6 responsive
我想更換respon
和r
與responsive
,所以最終的數據幀是
prod_type
0 responsive
1 responsive
2 responsive
3 responsive
4 responsive
5 responsive
6 responsive
我試圖以下但它沒有工作:
df['prod_type'] = df['prod_type'].replace({'respon' : 'responsvie'}, regex=True)
df['prod_type'] = df['prod_type'].replace({'r' : 'responsive'}, regex=True)
謝謝!有效。 –
@Carlton Gibson - 謝謝。 – jezrael