pymongo


Query with lambda function in pymongo?


I use the following query to fish for all men in a database:
f = pd.DataFrame(x for x in collection.find({"gender": "M"},{"_id":0}))
How could I find only the men where the "name" starts with an "A". Obviously I could filter the resulting huge DataFrame but how can I avoid creating this Frame in the first place.
Many thanks
You can use a MongoDB regular expression query, something like:
from bson.regex import Regex
f = pd.DataFrame(x for x in collection.find({"gender": "M", "name": Regex(r"^A.*")},{"_id":0}))

Related Links

mongoengine slow serialization of embedded documents with reference fields
Pymongo error : 'Cursor' object has no attribute 'find' , how to filter it?
Spark Streaming: foreachRDD insert into mongoDB using python?
how to find right version of bson from pip for pymongo/mongoengine
How to enable `projection` in pymongo query class `find()`?
Variables don't hold value for very long pymongo ipython
pymongo upgrade to 3.0.3 causes this statement to fail
UUID to NUUID in Python
how to test for empty mongodb query in pymong
read video file from mongodb with pymongo
Get OperationFailure error with PyMongo 2.7.1
Inserting string as regular string in mongodb
Mongos + Pymongo 2.5 ==>No suitable hosts found
pymongo collection add item using update
How to convert objectid to string
Conditional atomic mongo remove with different results

Categories

HOME
webview
gaming
redmine
writefile
swi-prolog
ios-simulator
biztalk
semantic-web
docker-cloud
malware
nsis
google-sheets-query
angular2-template
fbloginview
cname
feature-extraction
bundler
squid
mahout-recommender
pinterest
checkout
coroutine
azure-machine-learning
tableview
qa
animated-gif
sap-lumira
running-object-table
npoi
adapter
universal
android-collapsingtoolbar
polyml
assertions
runtimeexception
xvfb
sspi
linq.js
best-buy-api
newtons-method
vb.net-to-c#
ejml
optionaldataexception
virtual-memory
linq-to-excel
liteide
wysihtml5
django-static-precompiler
brightscript
gmaps.js
pjax
ndk-build
openquery
jpda
openseadragon
fragmentstatepageradapter
groovyfx
gnucash
exists
mathnet
trust
management-studio-express
ioexception
godeps
msgpack
chicagoboss
supersocket.net
vdm-sl
domino-designer-eclipse
bootstrap-wysiwyg
artisan
multivariate-testing
full-text-indexing
git-reset
meteor-collections
hotswap
ivalueconverter
usb-flash-drive
iosched
lsa
rautomation
notifyjs
lru
indesign-server
mongo-jackson-mapper
android-authenticator
audiotoolbox
struts2-s2hibernate
nsfont
django-pagination
ios-4.2
asdoc
zend-test
ppc
wmd-editor
eai
ntruencrypt

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App