我试图通过直接使用Yves Hilpisch博士的示例代码从netfonds网站下载HF数据,但是,我遇到了错误消息,例如
ValueError: No columns to parse from file
- 任何人都可以帮忙吗?非常感谢。
以下是示例代码:
import numpy as np
import pandas as pd
import datetime as dt
from urllib import urlretrieve
url1='http://hopey.netfonds.no/posdump.php?'
url2='date=%s%s%s&paper=AAPL.O&csv_format=csv'
url=url1+url2
year='2014'
month='09'
days=['23','24']
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']
AAPL.info()
错误信息如下:
Traceback (most recent call last):
File "<ipython-input-87-27cc48982059>", line 18, in <module>
index_col=0, header=0, parse_dates=True))
File "C:\Users\jinj\AppData\Local\Continuum\Miniconda\lib\site-packages\pandas\io\parsers.py", line 474, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\jinj\AppData\Local\Continuum\Miniconda\lib\site-packages\pandas\io\parsers.py", line 250, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "C:\Users\jinj\AppData\Local\Continuum\Miniconda\lib\site-packages\pandas\io\parsers.py", line 566, in __init__
self._make_engine(self.engine)
File "C:\Users\jinj\AppData\Local\Continuum\Miniconda\lib\site-packages\pandas\io\parsers.py", line 705, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\jinj\AppData\Local\Continuum\Miniconda\lib\site-packages\pandas\io\parsers.py", line 1072, in __init__
self._reader = _parser.TextReader(src, **kwds)
File "pandas\parser.pyx", line 512, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:4814)
ValueError: No columns to parse from file