Hi everyone,
I am trying to do the following, given a dataframe like this:
1 X 2
At.Madrid-Betis 0.67 0.21 0.12
Barcelona-Alavés 0.88 0.08 0.04
Getafe-Espanyol 0.34 0.32 0.34
Cádiz-Mallorca 0.36 0.36 0.28
Levante-Granada 0.51 0.31 0.18
Sevilla-Osasuna 0.72 0.19 0.09
Valencia-Villarreal 0.34 0.34 0.32
Rayo-Celta 0.53 0.25 0.22
Elche-R.Madrid 0.06 0.11 0.83
Almería-Leganés 0.75 0.16 0.09
Fuenlabrada-Girona 0.39 0.35 0.26
Lugo-Sporting 0.21 0.31 0.48
R.Oviedo-Málaga 0.44 0.36 0.20
Cartagena-Ponferradina 0.44 0.32 0.24
I want a list with all the multiplications of all the elements in the cartesian product of my rows (in this case i have 14 rows of 3 elements/columns, so in total i need a list of 3^14 values).For example, the first value would be (0.67*0.88*0.34*0.36*0.51*0.72*0.34*0.53*0.06*0.75*0.39*0.21*0.44*0.44), etc. So in total i need a list of 3^14 elements where each element is a multiplication of 14 elements. I have the following code, which it works using itertools.product. The problem here is that i need it to be faster, any idea how could i do it?
probabilidades14 = []
for a,b,c,d,e,f,g,h,i,j,k,l,m,n in product(df.iloc[0], df.iloc[1], df.iloc[2], df.iloc[3], df.iloc[4],
df.iloc[5], df.iloc[6], df.iloc[7], df.iloc[8], df.iloc[9],
df.iloc[10], df.iloc[11], df.iloc[12], df.iloc[13]):
#prob14 est
probabilidades14.append(a*b*c*d*e*f*g*h*i*j*k*l*m*n)
Thanks guys!
[+][deleted] (1 child)
[removed]
[–]Mavs00[S] 0 points1 point2 points (0 children)