...
Code Block | ||
---|---|---|
| ||
# ====== Inserting Documents ====== # # Creating a simple documentsPandas andDataFrame puttingliste_hello them in a list liste_docs=[{'message': 'helloworld1'},{'message': 'helloworld2'}]= ['hello1','hello2'] liste_world = ['world1','world2'] df = pd.DataFrame(data = {'hello' : liste_hello, 'world': liste_world}) # Bulk inserting documents collection. Each row in the DataFrame will be a document in Mongo db.insert_many(liste_docsdf.to_dict('records')) |
How to query a document from Mongo with Python ?
...
Code Block | ||
---|---|---|
| ||
# ====== Finding Documents ====== #
documents = collection.find({'message': 'helloworld1'})
df = pd.DataFrame(list(documents)) |