0

I am learning python, Pandas and data science. I used to do Vlookup in excel, now i want to learn it in python/Pandas. please help me understand below issue.

df1=
    titleId  title                         rating
    35423    Kate & Leopold                 PG-13
    79820    The King and the Mockingbird   Not Rated
    80339    Airplane!                      PG
    80360    Altered States                 R
    80365    American Gigolo                R

and

df2=
titleId   region    genres
35423     US       Comedy,Fantasy,Romance
79820     US       Animation,Family,Fantasy
80339     US       Comedy
80360     US       Horror,Sci-Fi,Thriller
80365     US       Crime,Drama,Mystery

I want to apply Excel like Vlookup in df1 to get only targeted column genres from df2. my desired output should be as below.

df1=
    titleId  title                          rating   genres
    35423    Kate & Leopold                 PG-13    Comedy,Fantasy,Romance
    79820    The King and the Mockingbird   Not      Rated  Animation,Family,Fantasy
    80339    Airplane!                      PG       Comedy
    80360    Altered States                 R        Horror,Sci-Fi,Thriller
    80365    American Gigolo                R        Crime,Drama,Myster

I dont want to be dependent on index, my index and order is different in both DataFrames.

Please Help guys, Thanks.

  • I closed your question because [this Q/A](https://stackoverflow.com/q/53645882/15239951) is exactly what you need and the explanation are really clear and interesting especially if you are starting with Pandas. – Corralien Nov 01 '21 at 21:05

0 Answers0