【问题标题】:ValueError: The Quandl API key must be providedValueError:必须提供 Quandl API 密钥
【发布时间】:2019-06-14 20:08:16
【问题描述】:

我已经导入了 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']

【问题讨论】:

    标签: python quandl


    【解决方案1】:

    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)
    

    【讨论】:

      猜你喜欢
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 2019-01-19
      • 2021-05-25
      相关资源
      最近更新 更多