Pandas find common matches between 2 dataframes

前端 未结 2 2066
心在旅途
心在旅途 2021-01-29 00:05

I have 2 dataframes and I want to find common matches based on a column (tld), once match has been found, I want to update column match as True. How to update column in destinat

2条回答
  •  醉酒成梦
    2021-01-29 00:26

    Using isin to update

    df2.loc[df2.tld.isin(df1.tld),'match']=True
    df2
    Out[669]: 
      id           website company_name           tld  match
    0  a  www.facebook.com     facebook  facebook.com   True
    1  b         www.y.com     YahooInc         y.com  False
    2  c         www.g.com       Google         g.com  False
    3  d         www.g.com    GoogleInc         g.com  False
    4  e  www.facebook.com  FacebookInc  facebook.com   True
    

提交回复
热议问题