data=https://bbs.csdn.net/topics/DataFrame ({' food ': [' bacon', 'pulled pork', 'honey ham],' ounce:,3,12 [4]})
Meat_to_animal={' bacon ':' pig ', 'pulled pork' : 'cow', 'honey ham' : 'pig'}
The meaning of the author is to which animal meat from additional, then gives the:
Data=data [' animal '] [' food ']. The map (lambda x: meat_to_animal [x]).
The use of the map is the map (function, iterable... ), common practice is:
A=[(' a ', 1), (" b ", 2), (' c ', 3), (' d ', 4)]
A_1=list (map (lambda x: x [0], a))
I don't understand is:
1, the use of the map
The map (lambda x: meat_to_animal [x]) why is meat_to_animal [x], shouldn't be a map (lambda x: x.v alues, meat_to_animal)//to be carried the values in the dictionary,
2, meat_to_animal [x] don't understand this usage
I small white, just learn soon, please bosses, glad to
Thank you again,
CodePudding user response:
Just search someone else's usage is:A=dict (addr='China' and name='samy')
> The map (lambda x: x.u pper (), Dr. Alues ())
[' CHINA 'and' SAMY]
But when I perform, wrong: