Insert a Pandas Dataframe into mongodb using PyMongo

Here you have the very quickest way. Using the insert_many method from pymongo 3 and ‘records’ parameter of to_dict method.

db.collection.insert_many(df.to_dict('records'))

Leave a Comment