Data pull

Having finished with the data retrieval, we can start the preparation of the data structures for further processing. We will load our data into the dataframe model.

Mongo connection object:

client = MongoClient('mongodb://localhost:27017/')
db = client['db']
collection = db['collection']

documents = []
for doc in collection.find():
documents.append(doc)

Now, we can create a dataframe object using our documents list:

df = pd.DataFrame(documents) 

So, our data structure is in tabular form, where columns indicate the names of the document nodes and the rows represent the data:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset