Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
# ====== 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
languagepy
# ====== Finding Documents ====== #
documents = collection.find({'message': 'helloworld1'})
df = pd.DataFrame(list(documents))