I have a pandas dataframe as below:
How can I combine all the lists (in the \'val\' column) into a unique list (set), e.g. [val1, val2, val33, val9, v
You can use str.concat followed by some string
manipulations to obtain the desired list
.
In [60]: import re
...: from collections import OrderedDict
In [62]: s = df['val'].str.cat()
In [63]: L = re.sub('[[]|[]]',' ', s).strip().replace(" ",',').split(',')
In [64]: list(OrderedDict.fromkeys(L))
Out[64]: ['val1', 'val2', 'val33', 'val9', 'val6', 'val7']