我已经导入了 quandl,但是我仍然收到此错误消息
import quandl
quandl.ApiConfig.api_key = 'X6mZSY79yeySfpCVJaKg'
ValueError: The Quandl API key must be provided either through the api_key variable or through the environmental variable QUANDL_API_KEY.
Mr_Techie = ['MSFT', 'NFLX', 'FB', 'AMZN']
Mr_Allstar = ['MSFT', 'PFE', 'F', 'WMT']
techie_potfolio = pd.DataFrame()
allstar_portfolio = pd.DataFrame()
for tech,allstar in zip(Mr_Techie, Mr_Allstar):
techie_portfolio[tech]= wb.DataReader(tech, data_source='quandl', start='2013-1-1')['AdjClose']
allstar_portfolio[allstar]= wb.DataReader(allstar, data_source='quandl', start='2013-1-1')['AdjClose']
最佳答案
source显示 DataReader 工厂函数如何将其传递给 Quandl 读取器:
elif data_source == "quandl":
return QuandlReader(symbols=name, start=start, end=end,
retry_count=retry_count, pause=pause,
session=session, api_key=access_key).read()
因此尝试使用 access_key 参数将其传递给 DataReader:
techie_portfolio[tech]=wb.DataReader(tech, data_source='quandl', start='2013-1-1',access_key=api-key)
关于python - 值错误: The Quandl API key must be provided,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54708709/