df4 = df[['user_id', 'rating_1']].rename(columns={'rating_1': 'rating'})
df = pd.merge(df1, df2, on='user_id', suffixes=['_1', '_2'])
df3 = df[['user_id', 'rating_1']].rename(columns={'rating_1': 'rating'})
df4 = df[['user_id', 'rating_2']].rename(columns={'rating_2': 'rating'})
pd.concat([df3, df4], axis=0)
Finding common rows (intersection) in two Pandas dataframes