Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.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 - Fatal编程技术网

python中要列出的特殊字符

python中要列出的特殊字符,python,pandas,Python,Pandas,我有数据帧 data2 = {'col0' : ['USD<500','AUD>100','GBP>200'], 'col1' : ['weights(kgs)','weights(lbs)','weights(gms)'], 'col2' : ['USD$500','AUD$400','GBP$450'], 'col3' : ['height[cm]','height[mm]','height[m]'],

我有数据帧

data2 = {'col0' : ['USD<500','AUD>100','GBP>200'],
         'col1' : ['weights(kgs)','weights(lbs)','weights(gms)'],
         'col2' : ['USD$500','AUD$400','GBP$450'],
         'col3' : ['height[cm]','height[mm]','height[m]'],
         'col4' : ['length*10%','length*100%','length*1000%'],
         'col5' : ['exp^2','exp^3','exp^4'],
         'col6' : ['length.height','height.weight','length.weight'],
         'col7' : ['len?ht','ht?wt','len?wt'],
         'col8' : ['length+height','height+weight','length+weight']}
df2 = pd.DataFrame(data=data2)
这些字符抛出错误为:无需重复 和“$”显示在所有字符串中

我可以知道如何提取字符吗

"<",">","-","/","@","!","~","#","&","?","`"," ",",",":",";"
预期结果

avaichars = ["<",">","(",")","$","[","]","%","*","^",".","?","+"]
avichars=[“”、“(“,”)、“$”、“[”、“]”、“%”、“*”、“^”、“?”、“+”]

看起来像
str.contains
也将regex作为默认值。
str.contains
函数有一个名为
regex
的参数,默认为true。尝试将其设置为false。正如注释所述,它似乎是一个正则表达式,因此可以通过在无法获取的字符串开头添加反斜杠来获取它。我检查了。是的,设置df2[col].str.contains(ch,regex=False)有效
"(",")","[","]","*","^",".","?","+","%"
avaichars = ["<",">","(",")","$","[","]","%","*","^",".","?","+"]