- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 bs4 解析一个 html 页面并提取一个表,下面给出了示例表,我试图将它加载到 pandas 中,但是当我调用 pddataframe = pd.read_html(LOTable,skiprows=2 , flavor=['bs4'])
我得到下面列出的错误,但我可以打印由 bs4 美化的表格
有什么建议可以解决这个问题而无需获取每个 td 并逐一读取吗?
<table cellpadding="5" cellspacing="0" class="borders" width="100%">
<tr>
<th colspan="2">
Learning Outcomes
</th>
</tr>
<tr>
<td class="info" colspan="2">
On successful completion of this module the learner will be able to:
</td>
</tr>
<tr>
<td style="width:10%;">
LO1
</td>
<td>
Demonstrate an awareness of the important role of Financial Accounting information as an input into the decision making process.
</td>
</tr>
<tr>
<td style="width:10%;">
LO2
</td>
<td>
Display an understanding of the fundamental accounting concepts, principles and conventions that underpin the preparation of Financial statements.
</td>
</tr>
<tr>
<td style="width:10%;">
LO3
</td>
<td>
Understand the various formats in which information in relation to transactions or events is recorded and classified.
</td>
</tr>
<tr>
<td style="width:10%;">
LO4
</td>
<td>
Apply a knowledge of accounting concepts,conventions and techniques such as double entry to the posting of recorded information to the T accounts in the Nominal Ledger.
</td>
</tr>
<tr>
<td style="width:10%;">
LO5
</td>
<td>
Prepare and present the financial statements of a Sole Trader in prescribed format from a Trial Balance accompanies by notes with additional information.
</td>
</tr>
</table>
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-20-12673b1a4bfc> in <module>()
10 #Read table into pandas
11 if first:
---> 12 pddataframe = pd.read_html(LOTable,skiprows=2, flavor=['bs4'])
13 first = False
14 pddataframe
C:\Program Files\Anaconda3\envs\LearningOutcomes\lib\site-packages\pandas\io\html.py in read_html(io, match, flavor, header, index_col, skiprows, attrs, parse_dates, tupleize_cols, thousands, encoding)
872 _validate_header_arg(header)
873 return _parse(flavor, io, match, header, index_col, skiprows,
--> 874 parse_dates, tupleize_cols, thousands, attrs, encoding)
C:\Program Files\Anaconda3\envs\LearningOutcomes\lib\site-packages\pandas\io\html.py in _parse(flavor, io, match, header, index_col, skiprows, parse_dates, tupleize_cols, thousands, attrs, encoding)
734 break
735 else:
--> 736 raise_with_traceback(retained)
737
738 ret = []
C:\Program Files\Anaconda3\envs\LearningOutcomes\lib\site-packages\pandas\compat\__init__.py in raise_with_traceback(exc, traceback)
331 if traceback == Ellipsis:
332 _, _, traceback = sys.exc_info()
--> 333 raise exc.with_traceback(traceback)
334 else:
335 # this version of raise is a syntax error in Python 3
**TypeError: 'NoneType' object is not callable**
最佳答案
感谢所有建议的答案和评论中的指点,我的菜鸟错误是我在使用 bs4 提取表格后将其放在变量中。我正在运行 pd.read_html(LOTable,skiprows=2, flavor='bs4')
当我需要运行 pd.read_html(LOTable.pretify(),skiprows=2, flavor= 'bs4')
关于python - Pandas read_html 导致 TypeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41651350/
我正在看这个很好的答案:https://stackoverflow.com/a/58211397/3502164 . 解决方案的开头包括: library(httr) library(xml2) gr
我正在尝试从 wiki URL 中提取美国各州,为此我正在使用 Python Pandas。 import pandas as pd import html5lib f_states = pd.rea
无法从 1,2,3,4,5,6 列中获取 CCCCCCC ,将 pd.read_html 格式更改为 123456 后,我的 预期结果 应保留 1,2,3,4,5,6 HTML 代码 html = "
尝试抓取网页标题,但在名为“tweg.com”的网站上遇到问题 library(httr) library(rvest) page.url % html_text() # from rvest r
我想迭代本地计算机上的多个目录,每个目录都包含一个 HTML 文件。我将每个文件的路径存储在列表变量中,但现在我想迭代每个文件并将其读入诸如 pd.read_html 之类的内容,以便从 HTML 文
我正在尝试保存通过 pd.read_html() 引入的多个表中的数据。如果我打印 df,我可以看到它捕获了所有数据,但是在保存数据时它只将第一个表保存到 excel。如何将表格分开,以便我可以将每个
我正在使用以下 read_html() 调用来读取表格(在付费专区后面): df = pd.read_html('http://markets.ft.com/data/equities/tearshe
我的目标是编写一个解析器,从给定的维基百科 URL 收集所有表格数据。我一直在尝试使用 pandas.read_html 方法从示例维基百科页面收集所有表格。不幸的是,它似乎并没有从页面中收集所有表格
我正在使用 pandas.read_html 读取一个 xlm 文件并且几乎完美地工作,问题是该文件使用逗号作为小数点分隔符而不是点(read_html 中的默认值>). 我可以很容易地用一个文件中的
我有这个简单的一行脚本: from pandas import read_html print read_html('http://money.cnn.com/data/hotstocks/', fl
我使用 pd.read_html() 从网页导入表格,但 Python 没有将数据结构化为数据框,而是将其导入为列表。如何将数据导入为数据框?谢谢! 代码如下: import pandas as pd
我正尝试通过此 URL 在 Yahoo Finance 中获取主要世界指数的列表:https://finance.yahoo.com/world-indices .我首先尝试通过运行来获取表中的索引
我用这个代码 library(rvest) url<-read_html("http://en.wikipedia.org/wiki/Brazil_national_football_team") 我
我想检索以下网站上的表格并将它们存储在 Pandas 数据框中:https://www.acf.hhs.gov/orr/resource/ffy-2012-13-state-of-colorado-o
我无法找到如何正确索引我的数据框列 我尝试了一些方法,但找不到合适的方法 import pandas as pd df = pd.read_html('sbi.html') data = df[1]
我正在尝试使用 Pandas read_html 函数获取股票代码列表(而不是使用 Beautiful Soup 来抓取网络)。 我引用的网站是: https://en.wikipedia.org/w
我正在使用 bs4 解析一个 html 页面并提取一个表,下面给出了示例表,我试图将它加载到 pandas 中,但是当我调用 pddataframe = pd.read_html(LOTable,sk
我可以使用下面的代码从一个 URL 打印/获取 CSV 数据框 import bs4 as bs import pandas as pd dfs = pd.read_html('http://www.
我正在使用 pandas 来抓取网站,但它返回的是一整列 'nan' 值,而不是正确的值。我尝试更改几个 read_html() 参数,例如 flavor、converters 和 na_values
我注册通过提供商获取货币价格。当我使用 pd.read_html('URL') 时,出现 403 错误 - 权限被拒绝。所以我然后尝试通过这样做来模拟浏览器- import pandas as pd
我是一名优秀的程序员,十分优秀!