1

I have two dataframe df1 and df2 for example:

df1:

 Account          Type
0 a              Green
1 a              Red  
2 a              Gala 
3 a              orange

df2:

  Account         Type
0 a             Green apple
1 a             Red  apple
2 a             Gala apple

What I need to do is to create a column in df1 called Type_2 where I will find the corresponded name for each type in df1 found in df2. In short, scan the whole array and get the result.

   Account      Type     Type_2
    0 a         Green   Green apple
    1 a         Red     Red apple
    2 a         Gala    Gala apple
    3 a         orange     Null

I am trying to learn, hope you can help me

  • Eh that dup isn't sufficiently focused enough for this problem. Use my answer here: https://stackoverflow.com/questions/65568862/how-set-value-in-column-according-to-another-dataframe-columns-value. You'll first need to use `.str.extract` to generate the exact keys you can then merge on (using that dup), though IMO the first part is the more difficult aspect – ALollz Mar 10 '21 at 20:43
  • I think the idea is in this way. However, I am not clear about how to call the pat thing in my case. – Saray Camargo Carrillo Mar 10 '21 at 21:39

0 Answers0