2017-12-27 4 views
1

MacBook Pro OS v10.13.2 (17C88)에서 Spyder3를 사용하여 Python 3.6에서 팬더를 사용하여 테이블 데이터를 고칩니다. 코드는 다음과 같습니다 콘솔에 표시TypeError : __init __()에서 예상치 못한 키워드 인수 '인코딩'이 발생했습니다.

import pandas as pd 
... 

url = "https://coinmarketcap.com/currencies/bitcoin/historical-data/?start=20130428&end="+time.strftime("%Y%m%d") 

# CODE FAILS HERE 
bitcoin_market_info = pd.read_html(url)[0] 

결과 :

bitcoin_market_info = pd.read_html(url)[0] 
Traceback (most recent call last): 

    File "<ipython-input-2-0b0d269a2c9d>", line 15, in <module> 
    bitcoin_market_info = pd.read_html(url)[0] 

    File "/Users/EL-C/anaconda3/lib/python3.6/site-packages/pandas/io/html.py", line 915, in read_html 
    keep_default_na=keep_default_na) 

    File "/Users/EL-C/anaconda3/lib/python3.6/site-packages/pandas/io/html.py", line 749, in _parse 
    raise_with_traceback(retained) 

    File "/Users/EL-C/anaconda3/lib/python3.6/site-packages/pandas/compat/__init__.py", line 385, in raise_with_traceback 
    raise exc.with_traceback(traceback) 

TypeError: __init__() got an unexpected keyword argument 'encoding' 

PD. 버전는 '0.21.1'pd.show_versions의

결과()이다 :

INSTALLED VERSIONS 
------------------ 
commit: None 
python: 3.6.4.final.0 
python-bits: 64 
OS: Darwin 
OS-release: 17.3.0 
machine: x86_64 
processor: i386 
byteorder: little 
LC_ALL: en_US.UTF-8 
LANG: en_US.UTF-8 
LOCALE: en_US.UTF-8 

pandas: 0.21.1 
pytest: 3.3.0 
pip: 9.0.1 
setuptools: 36.5.0.post20170921 
Cython: 0.27.3 
numpy: 1.13.3 
scipy: 1.0.0 
pyarrow: None 
xarray: None 
IPython: 6.2.1 
sphinx: 1.6.3 
patsy: 0.4.1 
dateutil: 2.6.1 
pytz: 2017.3 
blosc: None 
bottleneck: 1.2.1 
tables: 3.4.2 
numexpr: 2.6.4 
feather: None 
matplotlib: 2.1.1 
openpyxl: 2.4.9 
xlrd: 1.1.0 
xlwt: 1.2.0 
xlsxwriter: 1.0.2 
lxml: 4.1.1 
bs4: 4.6.0 
html5lib: 1.0.1 
sqlalchemy: 1.1.13 
pymysql: None 
psycopg2: None 
jinja2: 2.10 
s3fs: None 
fastparquet: None 
pandas_gbq: None 
pandas_datareader: None 

내가 시도 this 수정하지만, 주어진 이전 버전과 정확히이 상황 것으로 보인다 html5lib을 가져 오지 않았습니다.

이 경우 그것은 필요한 :

html5lib. 버전은 1.0.1

bs4입니다. 버전은 4.6.0

입니다. 터미널에서 'pip3 install -U html5lib == "0.9999999"(권장)를 실행해도 Spyder3의 버전은 변경되지 않습니다. 명령을 실행할 때 나는 터미널에 표시되는 내용

은 다음과 같습니다

Requirement already up-to-date: html5lib==0.9999999 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages 
Requirement already up-to-date: six in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from html5lib==0.9999999) 

어쩌면이 루트는? 그렇다면 이것을 알아내는 데 도움이 필요합니다.

+2

당신이 그대로 전체 역 추적을 게시 할 수 있습니까? –

+2

'url2'는'url'과 같은가요? –

+0

url2는 url과 동일합니다. 그것을 변경하고 추적을 추가하기 위해 질문이 업데이트되었습니다. – user

답변

0

시도 그것은 나를 위해 완벽하게 잘 작동 Anaconda Python distributive (available for Linux, Windows and MacOS

를 설치 :

In [133]: bitcoin_market_info = pd.read_html(url)[0] 

In [134]: bitcoin_market_info 
Out[134]: 
       Date  Open  High  Low  Close  Volume Market Cap 
0  Dec 26, 2017 14036.60 16461.20 14028.90 16099.80 13454300000 235294000000 
1  Dec 25, 2017 13995.90 14593.00 13448.90 14026.60 10664700000 234590000000 
2  Dec 24, 2017 14608.20 14626.00 12747.70 13925.80 11572300000 244824000000 
3  Dec 23, 2017 13948.70 15603.20 13828.80 14699.20 13086000000 233748000000 
4  Dec 22, 2017 15898.00 15943.40 11833.00 13831.80 22198000000 266381000000 
5  Dec 21, 2017 16642.40 17567.70 15342.70 15802.90 16516600000 278827000000 
6  Dec 20, 2017 17760.30 17934.70 16077.70 16624.60 22149700000 297526000000 
7  Dec 19, 2017 19118.30 19177.80 17275.40 17776.70 16894500000 320242000000 
8  Dec 18, 2017 19106.40 19371.00 18355.90 19114.20 14839500000 320000000000 
9  Dec 17, 2017 19475.80 20089.00 18974.10 19140.80 13314600000 326141000000 
...   ...  ...  ...  ...  ...   ...   ... 
1694 May 07, 2013 112.25 113.44  97.70 111.50   - 1248470000 
1695 May 06, 2013 115.98 124.66 106.64 112.30   - 1289470000 
1696 May 05, 2013 112.90 118.80 107.14 115.91   - 1254760000 
1697 May 04, 2013  98.10 115.00  92.50 112.50   - 1089890000 
1698 May 03, 2013 106.25 108.13  79.10  97.75   - 1180070000 
1699 May 02, 2013 116.38 125.60  92.28 105.21   - 1292190000 
1700 May 01, 2013 139.00 139.89 107.72 116.99   - 1542820000 
1701 Apr 30, 2013 144.00 146.93 134.05 139.00   - 1597780000 
1702 Apr 29, 2013 134.44 147.49 134.00 144.54   - 1491160000 
1703 Apr 28, 2013 135.30 135.98 132.10 134.21   - 1500520000 

[1704 rows x 7 columns] 

모듈의 버전 :

flavor : str or None, container of strings

The parsing engine to use. bs4 and html5lib are synonymous with each other, they are

both there for backwards compatibility. The default of None tries to

use lxml to parse and if that fails it falls back on bs4 + html5lib .

,369 :

In [135]: pd.show_versions() 

INSTALLED VERSIONS 
------------------ 
commit: None 
python: 3.6.3.final.0 
python-bits: 64 
OS: Windows 
OS-release: 7 
machine: AMD64 
processor: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel 
byteorder: little 
LC_ALL: en_US.UTF-8 
LANG: en_US 
LOCALE: None.None 

pandas: 0.21.1 
pytest: 3.3.0 
pip: 9.0.1 
setuptools: 36.5.0.post20170921 
Cython: 0.27.3 
numpy: 1.13.3 
scipy: 1.0.0 
pyarrow: 0.7.0 
xarray: 0.10.0 
IPython: 6.2.1 
sphinx: 1.6.3 
patsy: 0.4.1 
dateutil: 2.6.1 
pytz: 2017.3 
blosc: 1.5.1 
bottleneck: 1.2.1 
tables: 3.4.2 
numexpr: 2.6.4 
feather: 0.4.0 
matplotlib: 2.1.1 
openpyxl: 2.4.9 
xlrd: 1.1.0 
xlwt: 1.3.0 
xlsxwriter: 1.0.2 
lxml: 4.1.1 
bs4: 4.6.0 
html5lib: 1.0.1 
sqlalchemy: 1.1.13 
pymysql: 0.7.11.None 
psycopg2: 2.7.3.1 (dt dec pq3 ext lo64) 
jinja2: 2.10 
s3fs: None 
fastparquet: None 
pandas_gbq: None 
pandas_datareader: 0.5.0 

read_html()는 기본적 당 LXML (flavor=None)를 사용

+0

Python 배포판을 설치했습니다. 다시 시작되었습니다. 성공하지 못했습니다. 나는 pandas_datareader가 설치되어 있지 않은 것으로 나타났습니다. 그게 효과가 있니? – user

+0

@user, 아나콘다의 ipython 셸에서 실행 해 보셨습니까? 이 경우 pandas_datareader가 필요하지 않다고 생각합니다 ... – MaxU

+0

게시 한 링크에서 .pkg를 통해 배포판을 설치했습니다. 이 코드는 모두 Spyder3의 .py 파일에서 실행됩니다. 호프는 그것을 대답 - ipython 껍질에서 실행중인 당신이 말하는 '그것'은 확실하지 않았습니다. – user

관련 문제