sum function

mike20007 at gmail.com mike20007 at gmail.com
Thu Oct 4 16:52:50 EDT 2012


Hi All,

I am new to python and am getting the data from hbase. 
I am trying to do sum on the column as below


scanner = client.scannerOpenWithStop("tab", "10", "1000", ["cf:col1"])
total = 0.0
r = client.scannerGet(scanner)
while r:
  for k in (r[0].columns):
    total += float(r[0].columns[k].value)
  r = client.scannerGet(scanner)

print total

Do you know of better (faster) way to do sum?

Any thoughts please?

Thanks



More information about the Python-list mailing list