Fix Python – How to import data from mongodb to pandas?

I have a large amount of data in a collection in mongodb which I need to analyze. How do i import that data to pandas?
I am new to pandas and numpy.
The mongodb collection contains sensor values tagged with date and time. The sensor values are of float datatype.
Sample Data:
“_cls” : “SensorReport”,
“_id” : ObjectId(“515a963b78f6a035d9fa5….

Fix Python – Using .sort with PyMongo

With PyMongo, when I try to retrieve objects sorted by their ‘number’ and ‘date’ fields like this:
db.test.find({“number”: {“$gt”: 1}}).sort({“number”: 1, “date”: -1})

I get this error:
TypeError: if no direction is specified, key_or_list must be an instance of list

What’s wrong with my sort query?

Fix Python – TypeError: ObjectId(”) is not JSON serializable

My response back from MongoDB after querying an aggregated function on document using Python, It returns valid response and i can print it but can not return it.
TypeError: ObjectId(‘51948e86c25f4b1d1c0d303c’) is not JSON serializable

{‘result’: [{‘_id’: ObjectId(‘51948e86c25f4b1d1c0d303c’), ‘api_calls_with_key’: 4, ‘api_calls_per_….

Fix Python – mongodb: insert if not exists

Every day, I receive a stock of documents (an update). What I want to do is insert each item that does not already exist.

I also want to keep track of the first time I inserted them, and the last time I saw them in an update.
I don’t want to have duplicate documents.
I don’t want to remove a document which has previously been saved, but is not ….

Fix Python – How to sort mongodb with pymongo

I’m trying to use the sort feature when querying my mongoDB, but it is failing. The same query works in the MongoDB console but not here. Code is as follows:
import pymongo

from pymongo import Connection
connection = Connection()
db = connection.myDB
print db.posts.count()
for post in db.posts.find({}, {‘entities.user_mentions.screen_name’:1})….