Python Pandas read_html在从Wikipedi读取表时失败

2024-06-16 14:00:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用以下代码从Wikipedia页面读取表:

import pandas as pd
pd.read_html('https://en.wikipedia.org/wiki/2013–14_Premier_League')

这样做会产生以下错误:

^{pr2}$

我试过了

^{3}$

但还是会有同样的错误。以下工作:

import requests
r = requests.get('https://en.wikipedia.org/wiki/2017–18_Premier_League')
c = r.content
dfs = pd.read_html(c)

我想知道的是如何让pd.read_html()直接在url上工作而不使用requests。我对编码有什么不理解,还是熊猫的问题?在

我正在运行Pandas 0.21.1和python3.5.4的水蟒发行版。谢谢你的帮助。在


Tags: 代码httpsorgimportreadhtml错误wiki