我使用pandas通过使用pd.read_html(url)来读取html,但它总是显示类型错误。你能告诉我如何解决它吗? 我使用anaconda3和python 3.6
__init__() got an unexpected keyword argument 'encoding'
我的代码是:
import pandas as pd
df=pd.read_html('http://isin.twse.com.tw/isin/C_public.jsp?strMode=2',encoding='big5hkscs',header=0)
答案 0 :(得分:0)
尝试安装html5lib,在终端中写入:
pip install html5lib
如果它不起作用,请在IDE中验证您使用的是anaconda的python,请检查:
import sys
print(sys.path)
然后将它与terminal命令的输入进行比较,将其写入终端:
which python
输出应包含相同的路径。
答案 1 :(得分:0)
Pandas在version 0.15中将encoding
参数添加到read_html
。使用pd.__version__
检查您的版本。如果它低于0.15
,则使用conda upgrade pandas
进行升级,您应该很高兴。
答案 2 :(得分:0)
将html5lib重新安装或降级到版本0.999999999
pip install html5lib == 0.999999999
它对我有用