WGP*_*WGP 2 python null mongodb pymongo
我想使用 python 在 mongo 中查询空字段,但是它很难处理 null 或 false 这两个词。它要么给我一个错误,即它们在 python 中未定义,要么在 mongo 中搜索字符串 null 和 false,我不想发生这两种情况。
collection = pymongo.MongoClient('mongodb://localhost:27017/')['historical'].highjump
1) data = pd.DataFrame(list(collection.find({"min":"null"})))
2) data = pd.DataFrame(list(collection.find({"min":null})))
3) data = pd.DataFrame(list(collection.find({"min":{"$exists":"false"}})))
4) data = pd.DataFrame(list(collection.find({"min":{"$exists":false}})))
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激,我可以在 mongo 中运行查询 2 和 4 并返回正确的文档,但我需要从 python shell 运行它。