【问题标题】:How to store datasets and databases from quandl using quandl Python API/module in postgresql or mongodb?如何在 postgresql 或 mongodb 中使用 quandl Python API/模块从 quandl 存储数据集和数据库?
【发布时间】:2018-02-19 20:38:01
【问题描述】:

有人知道如何使用 Python 的 quandl 模块/API 将数据集和数据库存储到使用 postgresql 或 mongodb 的单个数据库中。任何帮助都感激不尽。谢谢。

【问题讨论】:

  • 如果我的回答帮助您解决了问题,您可以点赞并接受。否则,如果您详细说明您的问题,我很乐意继续为您提供帮助。

标签: django mongodb postgresql python-3.x quandl


【解决方案1】:

quandl API 返回的数据是 pandas 数据帧。

您可以像这样使用PyMongo 将 pandas 数据帧保存到 mongodb:

df = quandl.get("FRED/GDP",returns="pandas")
records = json.loads(df.T.to_json()).values()
db.myCollection.insert(records)

更多信息请参见this post

要写入 SQL 数据库,您可以在 pandas 数据帧上使用 to_sql 方法。更多信息请见this post

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多