Hi Andrej

This is something I've also struggled with in all kinds of ways and I'd be 
interested in any other replies.  

Here is a way I found to count the frequency of a single integer tag.  

rows=db().select(db.mytable.tag)
from collections import defaultdict
d = defaultdict(int)
for r in rows:
    d[r.tag] += 1
print d

Here is a way of counting the frequency of a list:integer:

rows=db().select(db.mytable.cat).as_list()
res = []
for r in rows:
    for i in r.itervalues():
        if i: res.extend(i)

from collections import defaultdict
d = defaultdict(int)
for r in sorted(res):
    d[r] += 1

print d


Once you have a dict of  {id:frequency}  I found the rest is easy.  
However,  I also feel sure there must be an easier way than I have found 
above.

Regards, D

-- 



Reply via email to