Hi,
After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:
Say
m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
r={'a':4, 'b':5, 'c':6}
What I need is the calculation
1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26
That is, for each row list in
After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:
Say
m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
assuming you meant ['c', 3] here...^
r={'a':4, 'b':5, 'c':6}
What I need is the calculation
1*4 + 2*5 + 3*4 = 4 + 10 + 12 =
On Aug 31, 6:30 pm, Tim Chase python.l...@tim.thechases.com wrote:
After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:
Say
m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
assuming you meant ['c', 3] here... ^ r={'a':4, 'b':5, 'c':6}
vsoler wrote:
On Aug 31, 6:30 pm, Tim Chase python.l...@tim.thechases.com wrote:
After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:
Say
m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
assuming you meant ['c', 3] here...^ r={'a':4, 'b':5,
vsoler vicente.so...@gmail.com writes:
m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
r={'a':4, 'b':5, 'c':6}
What I need is the calculation
1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26
sum(r[k]*w for k,w in m)
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 31, 6:59 pm, Tim Chase python.l...@tim.thechases.com wrote:
vsoler wrote:
On Aug 31, 6:30 pm, Tim Chase python.l...@tim.thechases.com wrote:
After simplifying my problem, I can say that I want to get the sum of
the product of two culumns:
Say
m= [[ 'a', 1], [ 'b', 2],[
31-08-2009 o 18:19:28 vsoler vicente.so...@gmail.com wrote:
Say
m= [[ 'a', 1], [ 'b', 2],[ 'a', 3]]
r={'a':4, 'b':5, 'c':6}
What I need is the calculation
1*4 + 2*5 + 3*4 = 4 + 10 + 12 = 26
That is, for each row list in variable 'm' look for its first element
in
31-08-2009 o 22:28:56 Jan Kaliszewski z...@chopin.edu.pl wrote:
setup = from itertools import starmap, imap ; from operator
import mul; import random, string; names = [rndom.choice(string.
ascii_letters) for x in xrange(1)]; hours = [random.randint(
1, 12) for x in xrange(1000)]; m =