I want to replace substring icashier.alipay.com
in column in df
url
icashier.alipay.com/catalog/2758186/detail.aspx
icashier.alipay.com/catalog/2758186/detail.aspx
icashier.alipay.com/catalog/2758186/detail.aspx
vk.com
to aliexpress.com
.
Desire output
aliexpress.com/catalog/2758186/detail.aspx
aliexpress.com/catalog/2758186/detail.aspx
aliexpress.com/catalog/2758186/detail.aspx
vk.com
I try df['url'].replace('icashier.alipay.com', 'aliexpress.com', 'inplace=True')
but it return empty dataframe
.
use
str.replace
to replace a substring,replace
looks for exact matches unless you pass a regex pattern and paramregex=True
:Use
replace
withdict
for replacing and parametersinplace=True
andregex=True
: