Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
difference between count() and python builtin len()
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
aliane abdelouahab  
View profile   Translate to Translated (View Original)
 More options Oct 5 2012, 5:30 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Fri, 5 Oct 2012 14:30:31 -0700 (PDT)
Local: Fri, Oct 5 2012 5:30 pm
Subject: difference between count() and python builtin len()
hi
it's a bizarre thing i got:

db.users.find({"adresse.coord":{"$within":{"$center":[[4.365041,
36.743954], 100]}}}).distinct("produit_up")
Out[17]:
[{u'avatar': {u'avctype': u'image/jpeg',
   u'orientation': u'portrait',
   u'photo': ObjectId('506f2ee93a5f3a0528ab8621')},
  u'spec': {u'abus': 0,
   u'date': u'2012-10-05',
   u'description': u'brrrrrrrrrrr',
   u'id': u'tofla134946378579',
   u'namep': u'nokia 6230',
   u'nombre': 2,
   u'prix': 1000,
   u'tags': [u'nokia', u'6230', u'photo'],
   u'vendu': False}},
 {u'avatar': {u'avctype': u'image/jpeg',
   u'orientation': u'portrait',
   u'photo': ObjectId('506867863a5f3a0ea84dcd6c')},
  u'spec': {u'abus': 0,
   u'date': u'2012-09-30',
   u'description': u"portable tr\xe8s solide, peu servi, avec batterie
d'une autonomie de 3 heures.",
   u'id': u'alucaard134901952647',
   u'namep': u'nokia 3310',
   u'nombre': 1,
   u'prix': 1000,
   u'tags': [u'portable', u'nokia', u'3310'],
   u'vendu': False}},
 {u'avatar': {u'avctype': u'image/jpeg',
   u'orientation': u'portrait',
   u'photo': ObjectId('506f2b3e3a5f3a0b3c4731a9')},
  u'spec': {u'abus': 0,
   u'date': u'2012-10-05',
   u'description': u'bzzzzzzzzzz',
   u'id': u'alucaard134946284638',
   u'namep': u'nokia 6230',
   u'nombre': 1,
   u'prix': 2000,
   u'tags': [u'nokia', u'nok', u'noki'],
   u'vendu': False}}]

db.users.find({"adresse.coord":{"$within":{"$center":[[4.365041,
36.743954], 100]}}}).count()
Out[18]: 2

len(db.users.find({"adresse.coord":{"$within":{"$center":[[4.365041,
36.743954], 100]}}}).distinct("produit_up"))
Out[19]: 3


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Oct 5 2012, 5:36 pm
From: Sam Millman <sam.mill...@gmail.com>
Date: Fri, 5 Oct 2012 22:36:05 +0100
Local: Fri, Oct 5 2012 5:36 pm
Subject: Re: [mongodb-user] difference between count() and python builtin len()

Distinct returns a single bson document, it's not like SQLs distinct, if I
remember right the function outputs three fields in that document, one
being the results.

On 5 October 2012 22:30, aliane abdelouahab <alabdeloua...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aliane abdelouahab  
View profile  
 More options Oct 5 2012, 5:38 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Fri, 5 Oct 2012 14:38:27 -0700 (PDT)
Local: Fri, Oct 5 2012 5:38 pm
Subject: Re: difference between count() and python builtin len()
ah! so the reliable is count() ?

On 5 oct, 22:36, Sam Millman <sam.mill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aliane abdelouahab  
View profile  
 More options Oct 5 2012, 5:43 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Fri, 5 Oct 2012 14:43:41 -0700 (PDT)
Local: Fri, Oct 5 2012 5:43 pm
Subject: Re: difference between count() and python builtin len()
because there is "really" 3 products and not "2" !!!

On 5 oct, 22:36, Sam Millman <sam.mill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Smith  
View profile  
 More options Oct 6 2012, 12:25 pm
From: Russell Smith <r...@rainforestapp.com>
Date: Sat, 6 Oct 2012 09:25:21 -0700
Local: Sat, Oct 6 2012 12:25 pm
Subject: Re: [mongodb-user] difference between count() and python builtin len()
Distinct returns unique values for the specified field

You may (if I recall correctly) be getting duplicated entires if you have more than one addresse field per document, as it may match twice.

Russ
Rainforest  |  +1-650-919-3216 |  rainforestqa.com

On Oct 5, 2012, at 2:36 PM, Sam Millman <sam.mill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aliane abdelouahab  
View profile  
 More options Oct 6 2012, 5:52 pm
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Sat, 6 Oct 2012 14:52:05 -0700 (PDT)
Local: Sat, Oct 6 2012 5:52 pm
Subject: Re: difference between count() and python builtin len()
here it's the coordinates, and because there is a duplicated value
that it has been omited to return 2 instead of 3?

On 6 oct, 17:25, Russell Smith <r...@rainforestapp.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Millman  
View profile  
 More options Oct 7 2012, 6:49 am
From: Sam Millman <sam.mill...@gmail.com>
Date: Sun, 7 Oct 2012 11:49:29 +0100
Local: Sun, Oct 7 2012 6:49 am
Subject: Re: [mongodb-user] Re: difference between count() and python builtin len()

Unless distinct works differently on the find of geospatial query then no
since the distinct would have have only two documents to distinct then.

On 6 October 2012 22:52, aliane abdelouahab <alabdeloua...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
aliane abdelouahab  
View profile  
 More options Oct 7 2012, 8:41 am
From: aliane abdelouahab <alabdeloua...@gmail.com>
Date: Sun, 7 Oct 2012 05:41:10 -0700 (PDT)
Local: Sun, Oct 7 2012 8:41 am
Subject: Re: difference between count() and python builtin len()
ah! now i get it,
it seems that mongodb becomes interresting more and more ;)
thank you :)

On 7 oct, 11:49, Sam Millman <sam.mill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »