[英]Pandas: read_html
我正在尝试从维基URL中提取美国各州,并且我正在使用Python Pandas。
import pandas as pd
import html5lib
f_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
但是,上面的代码给了我一个错误L.
(1)导入pandas中的ImportError Traceback(最近调用最后一次)为pd ----> 2 f_states = pd.read_html(' https://simple.wikipedia.org/wiki/List_of_U.S._states ')
如果在('bs4','html5lib')中有味道:662如果不是_HAS_HTML5LIB: - > 663引发ImportError(“找不到html5lib,请安装它”)664如果不是_HAS_BS4:665引发ImportError(“BeautifulSoup4(bs4)not not发现,请安装它“)ImportError:找不到html5lib,请安装它
我也安装了html5lib和beautifulsoup4,但它无法正常工作。 有人可以帮忙吗?
在mac上运行Python 3.4
新的pyvenv
pip install pandas
pip install lxml
pip install html5lib
pip install BeautifulSoup4
然后运行你的例子它应该工作:
import pandas as pd
import html5lib
f_states= pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
另请考虑在https://www.continuum.io/downloads上安装所需的软件包。 而不是pip安装,你会conda安装你的包。
$ conda install html5lib
你需要使用pip安装lxml。
pip install lxml
这对我有用。
为此你只需要安装
pip install pandas
pip install lxml
然后你必须导入它们并运行你的程序
import pandas as pd
f_states=pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
如果你的环境是Anaconda Jupiter笔记本。
你需要另一套安装评论:
conda install lxml
conda install html5lib
conda install BeautifulSoup4
然后在Jupiter笔记本中运行python代码。
import pandas as pd
f_states= pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.