
[英]AttributeError: 'DataFrame' object has no attribute '_loc'. Did you mean: 'iloc'? | PyCharm
[英]AttributeError: 'DataFrame' object has no attribute 'str'. Did you mean: 'std'?
我有一个 PDF 文件,我正在尝试使用正则表达式获取其中的特定数据,但出现以下错误。
这是我的 pdf 文件的内容: Question.pdf
import re
import tabula
df = tabula.read_pdf('Question.pdf', pages=1,lattice=True)[1]
df.columns = df.columns.str.replace('\r', ' ')
data = df.dropna()
data.str.extract(r'.*\?\s*(.*)')
data.to_excel('data.xlsx', index=False, header=None)
Traceback (most recent call last):
File "C:\Users\User1\Desktop\test.py", line 7, in <module>
data.str.extract(r'.*\?\s*(.*)')
File "C:\Users\User1\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\generic.py", line 5575, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'str'. Did you mean: 'std'?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.