在一个字符串中找到一个特定的符号,并在python中删除它左边和右边的一些字符
我有一个panda列,其中包含如下字符串:在一个字符串中找到一个特定的符号,并在python中删除它左边和右边的一些字符,python,pandas,dataframe,Python,Pandas,Dataframe,我有一个panda列,其中包含如下字符串: “[{'node':{'text':'2900”₸ 定义获取价格的函数(需要导入regex) 现在映射上述内容: df['price']=df['old_price'].map(get_price) 其中,‘old_price’是要减少的数据的列名 def get_price(s): match = re.search("^.+'(\d+₸).*", s) if match != None: ret
“[{'node':{'text':'2900”₸ 定义获取价格的函数(需要
导入regex
)
现在映射上述内容:
df['price']=df['old_price'].map(get_price)
其中,‘old_price’是要减少的数据的列名
def get_price(s):
match = re.search("^.+'(\d+₸).*", s)
if match != None:
return match.group(1)
else:
print('No match:', s)