Friday, 9 August 2013

find difference between lists and append difference to lists, but for 40 different lists - python

find difference between lists and append difference to lists, but for 40
different lists - python

Hi so it's difficult to explain this properly in the title, but firstly
let me start by explaining my data. I have 40 lists stored within a list
with a form such as this:
data[0] = [[value1 value2 value3,80],[value1,90],[value1
value3,60],[value2 value3,70]]
data[1] = [[value2,40],[value1 value2 value3,90]]
data[2] = [[value1 value2,80],[value1,50],[value1 value3,20]]
.
.
.
Now I am expecting an output such as this:
data[0] = [[value1 value2 value3,80],[value1,90],[value1
value3,60],[value2 value3,70],[value2,0],[value1 value2,0]]
data[1] = [[value2,40],[value1 value2 value3,90],[value1,0],[value1
value3,0],[value2 value3,0],[value1 value2,0]]
data[2] = [[value1 value2,80],[value1,50],[value1 value3,20],[value1
value2 value3,0],[value2 value3,0],[value2,0]]
I know this is a bit complicated to read, but I wanted to make sure a good
demo of the data is there. So basically all lists need to have all
possible combinations of the values present in all the lists, if the
combination isn't present in that list as standard then it's frequency
(the second field) is 0.
Thanks for any help, please bear in mind this is the intersection of 40
different lists and thus needs to be fast and efficient. I'm not sure how
best to do this...
EDIT: I also don't know all the 'values', I have just written 3 different
values here (value1, value2, value3) for simplicity. In my project I have
no idea what the values are or how many different ones there are (I know
there is at least a few 1000)

No comments:

Post a Comment