Merge two data frames based on common column values in Pandas

后端 未结 3 664
陌清茗
陌清茗 2020-11-27 16:02

How to get merged data frame from two data frames having common column value such that only those rows make merged data frame having common value in a particular column.

3条回答
  •  感情败类
    2020-11-27 16:41

    You can use pd.merge:

    import pandas as pd
    pd.merge(df1, df2, on="movie_title")
    

    Only rows are kept for which common keys are found in both data frames. In case you want to keep all rows from the left data frame and only add values from df2 where a matching key is available, you can use how="left".

提交回复
热议问题