I have the following problem: I have two pandas data frames of different length containing some rows and columns that have common values and some that are different, like this:<
Looks like you're looking for something like a left-join. See if this example helps: http://pandas.pydata.org/pandas-docs/stable/comparison_with_sql.html#left-outer-join
You can basically pass a parameter to merge()
called how='left'
You can simply use merge with using on and list as well
result = df1.merge(df2, on=['Column1'])
For more information follow link
You can read the documentation here: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html
What you are looking for is a left join. The default option is an inner join. You can change this behavior by passing a different how argument:
df1.merge(df2,how='left', left_on='Column1', right_on='ColumnA')