有谁知道如何使用 Python 的 quandl 模块/API 使用 postgresql 或 mongodb 将数据集和数据库存储到单个数据库中。任何帮助都感激不尽。谢谢。
最佳答案
从 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了解更多信息
关于django - 如何在 postgresql 或 mongodb 中使用 quandl Python API/模块存储来自 quandl 的数据集和数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46158485/