Merge two data frames based on common column values in Pandas

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":

pd.merge(df1, df2, on="movie_title", how="left")

Leave a Comment