0

I have two large dataframes(df1 and df2). df1 is comprised of basketball players and df2 is comprised of famous athletes from varying sports. I am trying to create a function that will search if the name of the basketball player in df1 is in df2, if true append it to a matched column and add string x to the description column, if false append nan. How do I do that?

x = 'basketball player'

df1 | Player | Team | Matched | Description | | ------ | ---- | ------- | ----------- | | Michael Jordan | Chicago Bulls | | | | Kobe Bryant | Los Angeles Lakers | | | | Lebron James | Los Angeles Lakers | | |

df2 | Player | Sport | Position | | ------ | ----- | -------- | | Deion Sanders | Football | DB | | Michael Jordan | Basketball | SG | | Barry Sanders | Football | RB | | Kobe Bryant | Basketball | SG |

expected outcome df1 | Player | Team | Matched | Description | | ------ | ---- | ------- | ----------- | | Michael Jordan| Chicago Bulls| Michael Jordan| basketball player| | Kobe Bryant| Los Angeles Lakers| Kobe Bryant| basketball player| | Lebron James| Los Angeles Lakers| nan| nan|

0 Answers0