I need to convert a list values according to values contained into a Python dictionary.
I have a list as the following:
lst = ["hello", "word", "bye", "my", "friend", "hello"]
And a dictionary obtained using a cluster procedure, so the keys are the labels and the values the categories:
my_dict = {0: ["hello", "word"], 1: ["my", "friend"], 2: ["bye"]}
I need to faster convert the original list into:
new_lst = [0, 0, 2, 1, 1, 0]
Consider that in the real case the list length is near 60k and so I need an efficient way to do this operation.