【问题标题】:get only a value with Quandl in Python在 Python 中使用 Quandl 只获取一个值
【发布时间】:2020-08-15 00:03:18
【问题描述】:

我正在与 Quandl 合作。我在文档中搜索过,但我找不到它

import quandl

quandl.ApiConfig.api_key = 'PNPLwChDhr6UMUVvfc5h'
gold = quandl.get('LBMA/GOLD', rows=1, column_index='2')

print(gold)

当我运行它时,控制台显示:

  USD (PM)
Date                
2020-08-13   1944.25

但是,我只需要 1944.25 将其与 if 语句进行比较。 怎么能只打印具体的值?

【问题讨论】:

    标签: python-3.x quandl


    【解决方案1】:

    代码:

    import quandl
    
    quandl.ApiConfig.api_key = 'your-api-key'
    gold = quandl.get('LBMA/GOLD', rows=1, column_index='2')
    
    print(gold.iloc[0].values[0])
    

    输出:

    1944.75
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      相关资源
      最近更新 更多