I want to pass a full array into a dictionary as keys and get the values out:
dic = {1:'a', 2:'b', 3:'c'}
lista = [1,2,3]
dic.get(1)
'a'
dic.get(list)
error
thanks
I want to pass a full array into a dictionary as keys and get the values out:
dic = {1:'a', 2:'b', 3:'c'}
lista = [1,2,3]
dic.get(1)
'a'
dic.get(list)
error
thanks
You could use operator.itemgetter here.
from operator import itemgetter
dic = {1:'a', 2:'b', 3:'c'}
lst = [1, 2, 3]
itemgetter(*lst)(dic)
# ('a', 'b', 'c')
in pandas its called the map function:
lista = lista.map(dic)
cheers
lista Series object?