Add column to dataframe from key values from dictionary

Hello again to All…I have dictionary and dataframe…I would like to add a column to dataframe with key and values matches with the first column…looking forward for your help…thanks

dict = {
  "11": "Cat.doc",
  "12": "Dog.doc",
  "13": "Duck.doc"


Col1		Col2(new) 
Cat.doc		11
Dog.doc		12
Duck.doc		13

***I would like to add Col2 with key and values match with dict and Col1 (example above)

By the example you provided, it seems like you want to flip the dictionary as well.

flipped_dict = dict(zip(d.values(), d.keys()))

df["Col3"] = df["Col2"].map(flipped_dict)

1 Like

Thank you so much…actually i look also online to find the solution,i am having trouble to get what i want NOT until i found your flip method…thanks a lot again

1 Like