Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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 3.x Pandas.str.extract无法处理字符串_Python 3.x_String_Pandas_Extract - Fatal编程技术网

Python 3.x Pandas.str.extract无法处理字符串

Python 3.x Pandas.str.extract无法处理字符串,python-3.x,string,pandas,extract,Python 3.x,String,Pandas,Extract,我有如下内容的单元格: {'Code':'YewrH','Owner':'yyy。xxx@cccc.com“,”环境类型“:”产品“,”ID“:”23000“,”信息安全“:”内部“,”PDDA“:”基本“,”级别“:”基本“,”联系人“:”czcxc。zxcxc@yyy.com“} 这些单元格位于名为“标记”的列中。所以我试着: tmp['tags'].str.extract(r'ID\':\s\'(\d*)\'', expand=True) 我希望正则表达式返回23000,但我得到

我有如下内容的单元格:

{'Code':'YewrH','Owner':'yyy。xxx@cccc.com“,”环境类型“:”产品“,”ID“:”23000“,”信息安全“:”内部“,”PDDA“:”基本“,”级别“:”基本“,”联系人“:”czcxc。zxcxc@yyy.com“}

这些单元格位于名为“标记”的列中。所以我试着:

    tmp['tags'].str.extract(r'ID\':\s\'(\d*)\'', expand=True)
我希望正则表达式返回23000,但我得到的唯一信息是:NaN。有人能帮忙吗

我发现这是有效的: tmp['tags']=tmp['tags'].astype(str)
tmp['APM\u id']=tmp['tags'].str.extract(r'id\':\s\'(\d*)\'',expand=True)

您没有为
使用转义字符。简单地说

tmp['tags'].str.extract(r'ID\'\:\s\'(\d*)\'')

谢谢,但我有比这更大的问题,我无法解决。由于某种原因,根本没有正则表达式可以工作。我想知道数据类型是否有问题。我在这些单元格上执行其他“操作”时遇到问题。我对Python不太了解,它有时会说“不可散列”…如果我将列转换为字符串,它就会像预期的那样工作。。。。