I have a set of lists of items FreqItemsets, for example :
FreqItemset(items=[u'bbb_1', u'ccc_1', u'ccc_2', u'aaa_1', u'ccc_3'], freq=379)
FreqItemset(items=[u'aaa_1_1', u'ccc_1', u'ccc_2', u'ccc_3'], freq=375)
...
I try to find in each FreqItemset an item starts from aaa
I know how to find aaa in first element of the list
filtered_result = model.freqItemsets()\
.filter(lambda x: x.items[0].startswith('aaa_')).collect()
The question is how to find aaa in each element of FreqItemset?
In first line of example above aaa string in forth place.
I thought about something like this :
filtered_result = model.freqItemsets()\
.filter(lambda x: x.items[0].startswith('aaa_'))
.filter(lambda x: x.items[1].startswith('aaa_'))
.filter(lambda x: x.items[2].startswith('aaa_'))
...
.collect()
is it most efficient way?
itemsare not lists of sets. Those are lists of unicode strings. Do you know how to do this with a 'normal' list (Python's default datatypelist)? That would be a starting point in combination with so calledlist comprehensions.