Map list from dictionaries
IIUC you could use simple list comprehension
for that:
[dictionary[key] for key in list_to_be_mapped]
In [51]: [dictionary[key] for key in list_to_be_mapped]
Out[51]: [1, 1, 2, 6, 6, 1]
If you prefer pandas
solution you could convert your list_to_be_mapped
to Series and then use the same as in your example:
s = pd.Series(list_to_be_mapped)
In [53]: s
Out[53]:
0 a
1 a
2 b
3 c
4 c
5 a
dtype: object
In [55]: s.map(dictionary).tolist()
Out[55]: [1, 1, 2, 6, 6, 1]
You can use the dictionary
's get
function
list(map(dictionary.get, list_to_be_mapped))