04pallav
9/11/2017 - 10:29 PM

map dataframe

map dataframe

dframe = DataFrame({'city':['Alma','Brian Head','Fox Park'],'altitude':[3158,3000,2762]})
#Now let's say we wanted to add a column for the States, we can do that with a mapping.
state_map={'Alma':'Colorado','Brian Head':'Utah','Fox Park':'Wyoming'}
dframe['state'] = dframe['city'].map(state_map)
#series1.map(dict1)
#statemap is a dictionary linking object to required mapping