- Pandas数据分析快速上手500招(微课视频版)
- 罗帅 罗斌编著
- 198字
- 2023-07-17 18:40:31
069 从指定的网页中读取多个表格的数据
此案例主要演示了使用read_html()函数根据网址读取指定网页的多个表格数据。当在Jupyter Notebook中运行此案例代码之后,将读取在指定网址(https://www.runoob.com/tags/ref-canvas.html)中的多个表格数据,效果分别如图069-1~图069-3所示。

图069-1

图069-2
主要代码如下。

在上面这段代码中,dfs = pd.read_html('https://www.runoob.com/tags/ref-canvas. html')表示读取在指定网址https://www.runoob.com/tags/ref-canvas.html中的多个表格数据。dfs[0]表示该网页的第1个表格,如图069-2所示。dfs[1]表示该网页的第2个表格,如图069-3所示。其余以此类推。

图069-3
此案例的主要源文件是MyCode\H253\H253.ipynb。