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
[val1, val2, val33, val9, v
One way would be to extract those elements into an array using np.hstack and then using np.unique to give us an array of such unique elements, like so -
np.hstack
np.unique
np.unique(np.hstack(df.val))
If you want a list as output, append with .tolist() -
.tolist()
np.unique(np.hstack(df.val)).tolist()