[Chicago] 2 unique keys in a python dict?

Massimo Di Pierro mdipierro at cs.depaul.edu
Thu Oct 9 20:02:13 CEST 2008


Not quite the same. I believe Lukasz is not looking into adding up the  
column. He is looking into grouping records by transaction id and than  
summing up records within the same transaction.


On Oct 9, 2008, at 11:53 AM, John Hunter wrote:

> On Thu, Oct 9, 2008 at 11:19 AM, Massimo Di Pierro
> <mdipierro at cs.depaul.edu> wrote:
>
>>>>> rows 
>>>>> = 
>>>>> db 
>>>>> ().select 
>>>>> (db 
>>>>> .mytable 
>>>>> .ttid 
>>>>> ,db 
>>>>> .mytable 
>>>>> .paid.sum(),orderby=db.mytable.ttid,groupby=db.mytable.ttid)
>>>>> for row in rows:
>> ... print 'transaction',row.ttid,'total  
>> amount',row[db.mytable.paid.sum()]
>
> Or use matplotlib's support for CSV files via numpy record arrays
>
>  import matplotlib.mlab as mlab
>  r = mlab.csv2rec('myfile.csv')
>  print r.paid.sum()
>
> csv2rec does type inference from the data in the file, and numpy
> arrays support all the standard math and stat operations (mean, std,
> logical masks, etc...)
>
> JDH
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago



More information about the Chicago mailing list