我正在学习Python for Python'并且使用的包已过时。请帮我解决以下错误: 它显示EmptyDataError:没有要从文件解析的列。
import pandas as pd
url1 = 'http://hopey.netfonds.no/posdump.php?'
url2 = 'date=%s%s%s&paper=AAPL.O&csv_format=csv'
url = url1 + url2
year = '2017'
month = '11'
days = ['9']
AAPL = pd.DataFrame()
for day in days:
AAPL = AAPL.append(pd.read_csv(url % (year, month, day),
index_col=0, header=0, parse_dates=True))
AAPL.columns = ['bid', 'bdepth', 'bdeptht','offer', 'odepth', 'odeptht']
错误:
EmptyDataError: No columns to parse from file
答案 0 :(得分:1)
Pandas问题导致此错误。
ke:
HTTP/1.1 200 OK
Date: Tue, 22 May 2018 01:18:42 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.25
Content-Disposition: attachment; filename=exams.csv
Pragma: no-cache
Expires: 0
Content-Type: text/csv
这意味着内容通过附件发送,文件名为exams.csv。
3.为了解决这个问题,请将此问题解决给pandas团队。
阅读:
from io import StringIO
import pandas as pd
import requests
url='https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv'
s=requests.get(url).text
c=pd.read_csv(StringIO(s))