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

pymongo collection add item using update
How to convert objectid to string
Conditional atomic mongo remove with different results
python script to connect to mongodb master
flask-admin and pymongo search
Running code when mongoengine loads a document
Can't replace mongo document
How do I call a function with pymongo using webpy?
python motor offers fetch_next exception on aggregation
python motor mongo cursor length or peek next
PyMongo check if update succeeded
insert and query an OrderedDict in MongoHQ
Return .str of ObjectID using pymongo
Selecting the lowest/highest with find_one in Pymongo
Safe use of Pymongo's find_one
Pymongo $in + $regex

Categories

HOME
php
amazon-web-services
knockout.js
list
typelite
yahoo-weather-api
writefile
embedded-resource
ios-simulator
liferay-7
visualforce
gprs
pyresttest
polymer-2.x
eddystone
siesta
fireloop
android-externalstorage
createjs
freertos
outlook-restapi
sql-injection
cocos2d-android
fido-u2f
perfino
webviewclient
clipboard
android-service
history.js
python-imageio
php-5.3
bitbake
javax.persistence
region
guice
xenapp
phpstorm-2016.1
memory-fences
seafile-server
android-canvas
assemblies
task-parallel-library
google-prediction
julius-speech
rm
gestures
popen
zend-server
ltrace
front-camera
nitrousio
livereload
nunit-console
always-on-top
system.net.mail
oci
groovyfx
maximize
timestamping
seadragon
gdl
json-spirit
msgpack
stack-smash
canopy
jnlp
blockquote
componentart
textscan
scala-swing
mgwt
camus
signed
baseadapter
phonegap-facebook-plugin
lifetime
box2dweb
forceclose
ivalueconverter
profiles
smips
visual-c++-2005
ax
xs
spiral
asp.net-mvc-3-areas
border-box
telerik-ajax
image-scanner
series-40
qt-mobility
database-deadlocks
uipasteboard
page-curl
kext
qcar-sdk
eaccelerator
android-input-method
resharper-5.0
gui-designer
rendering-engine

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App