我已经导入了quandl,但是我仍然收到此错误消息

import quandl
quandl.ApiConfig.api_key = 'X6mZSY79yeySfpCVJaKg'



  ValueError:必须通过api_key变量或通过环境变量QUANDL_API_KEY提供Quandl API密钥。


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 - ValueError:必须提供Quandl API key ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54708709/

10-12 22:11