Dec-11-2018, 08:12 PM
I am using the Quandl python api. I downloaded data and the data was returned into a pandas dataframe. I use to_json(None, orient='records') function and tried to insert it into my collection in the mongo db I get the following error "TypeError: document must be an instance of dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a type that inherits from collections.MutableMapping" how can I solve this problem?
import pandas as pd
import quandl
import pymonogo
def main():
data = quandl.get("WIKI/GOOG", returns="pandas")
data_json = data.to_json(None, orient='records')
client = pymongo.MongoClient('mongodb://localhost:27017/')
db = client.testdb
db.testdb.insert_many(data_json)
if __name__ == '__main__':main()