Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在一个字符串中找到一个特定的符号,并在python中删除它左边和右边的一些字符_Python_Pandas_Dataframe - Fatal编程技术网

在一个字符串中找到一个特定的符号,并在python中删除它左边和右边的一些字符

在一个字符串中找到一个特定的符号,并在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

我有一个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:
        return match.group(1)
    else:
        print('No match:', s)