I am trying to replace values. My dictionary is
apple=fruit
tomato=vegetable
steak=protein
milk=dairy
trying to change this col1
col1 -> col1
apple fruit
apple fruit
tomato vegetable
steak protein
milk dairy
When I try the code I am getting an error message?
d = {'apple': 'fruit',
'tomato': 'vegetable',
'steak': 'protein',
'milk': 'dairy'}
df[col1]=df.col1.map(d)
any help?
edit
df['col1']=df['col1'].map(d)
the values here aren't being saved to the pandas dataframe