- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
执行以下行时:
df = df[df['Directory'].str.contains("C:\Windows\System32\Tasks")]
我收到以下错误:
File "/Users/patrickmaynard/Desktop/CSVparser/parse.py", line 80, in parseFoundFiles
df = df[df['Directory'].str.contains("C:\Windows\System32\Tasks")]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/strings.py", line 1562, in contains
regex=regex)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/strings.py", line 249, in str_contains
regex = re.compile(pat, flags=flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 233, in compile
return _compile(pattern, flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 856, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, False)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 415, in _parse_sub
itemsappend(_parse(source, state, verbose))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 501, in _parse
code = _escape(source, this, state)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/sre_parse.py", line 401, in _escape
raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \T at position 19
我尝试过其他文件路径,它们工作得很好。我没有包含更多代码,因为我确信它没有影响这一行。我相信这可能是 pandas 或正则表达式中的一些奇怪的故障,是这种情况还是我犯了错误?
最佳答案
str.contains
默认情况下尝试使用正则表达式,因此 \T
尝试将其读取为特殊字符。您可以告诉它不要使用正则表达式,并通过输入 regex=False
来搜索您的确切字符串:
df[df['Directory'].str.contains("C:\Windows\System32\Tasks", regex=False)]
示例:
>>> df
Directory
0 C:\Windows\System32\Tasks\123
1 C:\Windows\System32\Tasks\456
2 C:\Windows\
3 xyz
>>> df[df['Directory'].str.contains("C:\Windows\System32\Tasks", regex=False)]
Directory
0 C:\Windows\System32\Tasks\123
1 C:\Windows\System32\Tasks\456
关于python - Pandas 错误转义 %s"% escape, len(escape),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51772905/
给定 data Person = Person { _name :: String } makeClassy ''Person 它创建了一个 name :: Lens' Person String 我
Python内置的len()函数的成本是多少?(列表/元组/字符串/词典)
这个问题在这里已经有了答案: 9年前关闭。 Possible Duplicate: lenses, fclabels, data-accessor - which library for struct
Python 哪个性能更好: 1) for i in range(len(a[:-1])): foo() 或 2) for i in range(len(a)-1): foo() 更新
我正在学习 Python 并正在学习谷歌代码类(class)。在 list2.py 示例中,他们要求我们编写一个函数: Given two lists sorted in increasing ord
我最近开始使用 Python 进行数据分析,由于我不是从头开始学习 Python,所以我觉得我错过了一些细微差别。 我注意到的一件事是,在我的一份报告中,我从 CSV 文件中导入了一个数据集,将其作为
为什么a[len(a):] = [x]等同于a.append(x),但是a[len(a) ] = [x] 给出超出范围的错误? 最佳答案 根据 the documentation (强调我的): If
当我运行以下宏时: Sub try() Dim num As Integer num = 123 MsgBox Len(num) MsgBox VBA.Len(num)
我目前正在获取 Python 3.x 中以 0 的随机长度结尾的随机数列表。例如,我得到以下一组随机数字字符串: String 1 = 203502000000 String 2 = 30293300
我正在学习 numba 并遇到了这种我不理解的“奇怪”行为。我尝试使用以下代码(在 iPython 中,用于计时): import numpy as np import numba as nb @nb
在Go , 要检查字符串是否为空,可以使用: len(str) == 0 或 len(str) < 1 或 str == "" 基本上就是选择运营商的一米== , < , != ,但就性能而言希望选项
我正在尝试创建一个函数 hpure通过重复相同的元素直到达到所需的长度来生成 hvect。每个元素可能有不同的类型。例如:如果参数是 show 每个元素将是 show 函数的特化。 hpure sho
我正在实现一个图形操作脚本,但我对以下错误感到困惑: Traceback (most recent call last): File ".....py", line 12, in pri
通常为了节省一些时间,我希望我们在本地函数中使用 n = len(s)。我很好奇哪个调用更快或者它们相同? while i < len(s): # do something 对比 while i
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
大家好! 我从这个网站找到了这段很棒的代码: var points = [30,100]; document.getElementById("demo").innerHTML = myArrayMax
我有一个输出 17 个维度的解码器,其中不同部分是标签和数字。因此,对于标签,我使用了 one-hot 编码并使用“softmax”激活,对于数字,我使用了“sigmoid”激活函数。 这是解码器:
我在下面得到了这段代码,但即使调试它,我也不明白为什么给出 7 而不是 6。 更准确地说,当我调试每个返回时都会给我预期的结果: 第一个函数调用:ipdb> --Return-- ['a'] 第二个函
上述分配可能会出现什么样的问题?如果我们分配实际数据类型的大小而不是该类型指针的大小? 对于 sizeof (char*) > sizeof (char) 的字符来说,这会是一个问题吗?其他数据类型和
我知道 somelist[len(somelist)] 无法访问定义列表之外的索引 - 这是有道理的。 但是为什么 Python 允许你做 somelist[len(somelist):]? 我什至读
我是一名优秀的程序员,十分优秀!