【问题标题】:Pandas datareader 'iex-last' results in "failed to interpret response as JSON"Pandas datareader 'iex-last' 导致“无法将响应解释为 JSON”
【发布时间】:2022-04-14 09:57:00
【问题描述】:

我正在尝试从 iex 获取 TLT 的最新价格。上个月试的时候还可以,今天试的时候报错:

TypeError: Failed to interpret response as JSON

我使用的代码是:

import pandas as pd
from pandas_datareader import data

tlt_price = data.DataReader('TLT', 'iex-last')

我尝试使用文档页面上的示例:

import pandas_datareader.data as web
f = web.DataReader('gs', 'iex-tops')
f[:10]

但同样的错误发生了。 知道如何让它再次工作吗?

谢谢!

【问题讨论】:

    标签: python python-3.x pandas pandas-datareader


    【解决方案1】:

    首先,来自 pandas-datareader 文档
    使用 IEX 时必须提供 API Key

    EX.os.environ["IEX_API_KEY"] = "pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

    然后,我只需在https://iexcloud.io 上创建一个帐户即可获得我的令牌

    最后我的 df 是这样的

    start = datetime(2017, 1, 1)
    end = datetime(2017, 12, 31)
    df = web.DataReader('TSLA','iex',start,end)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      • 1970-01-01
      • 2014-07-18
      • 1970-01-01
      • 2018-06-19
      相关资源
      最近更新 更多