【发布时间】:2019-03-01 11:01:12
【问题描述】:
我正在尝试替换两个特定措辞之间的字符串列中的值
例如,从这个数据框我想改变
df
seller_name url
Lucas http://sanyo.mapi/s3/e42390aac371?item_title=Branded%20boys%20Clothing&seller_name=102392852&buyer_item=106822419_1056424990
到这里
url
http://sanyo.mapi/s3/e42390aac371?item_title=Branded%20boys%20Clothing&seller_name=Lucas&buyer_item=106822419_1056424990
查看网址中seller_name=部分我换成了真名,我把数字换成了真名。
我想像从seller_name= 更改为第一个,然后从seller_name 看到。
这只是我想做的一个例子,但实际上我的数据框中有很多行,卖家名称中的数字长度并不总是相同
【问题讨论】:
-
您不能将
&的字符串拆分成一个列表,然后将seller_name的列表元素替换为卖家名称并将列表连接回一个字符串吗?您也可以使用正则表达式替换stackoverflow.com/questions/11475885/python-replace-regex
标签: python string python-3.x dataframe