I have a dataframe with and id and value columns.
df=
id val
'a' 1
'b' 3
'c' 9
....
I have a list of (repeated) id values.
i_list=['a','a','a','b']
I need to map this list of (repeated) id values into the corresponding (repeated) value columns, using the dataframe pairs (id,val)
out_desired=[1,1,1,3]
Right now I am doing:
out_desired=[df[df.id==curr_id].val.values for curr_id in i_list ]
How to do this in a more efficient yet still concise way?