I have a list of list a
as follows:
[[u'Apple', '', u'Apple Inc', u'Apple', u'shares ', u'Amazon', u'Amazon', u'Amazon', '', '', u'Apple', u'Kindle', u'iPad', u'Amazon', u'Amazon', '', u'Amazon', u'Kindle', u'Amazon', '', u'iPad', u'iPad', u'iPad', u'Kindle', u'Kindle', u'Nook', u' ', u'sales', '', '', u'Amazon', '', '', '', '', '', ''], [u'United Kingdom', ''], [u'LA']]
I need to remove the duplicates and the blanks in this. I tried the following:
a_1 = filter(None,a)
a_2 = list(set(a_1))
This doesn't seem to work because of the error TypeError: unhashable type: 'list'
. I tried to convert the list into tuples, but it also didn't work.
a_1 = set(map(tuple,a))
a_2 = map(list,a_1)
I have to preserve the order also. Can someone help me out with this.
Thanks.