As trivial as this questions sounds, an excessive search yield no results. In pandas
, you can select single "elements" using df['row1']
, and multiple elements using df[['row1', 'row2']
.
Since it inhibits a lot of functionality from dictionaries and and numpy, I thought that something along these lines should also be possible for dictionaries: (How) Can I select multiple values from a dictionary?
That is, given
myDict = {'a':1, 'b':2, 'c':3}
myList = ['a', 'c']
is there a simple way to select something as myDict[myList]
? Expected outcome is
[1, 3]
I suppose there is some way iterating through the list as foo = [myDict[x] for x in myList]
, but I'm thinking of straight notation without having to iterate myself.