Merge two python pandas data frames of different length but keep all rows in output data frame

后端 未结 3 690
甜味超标
甜味超标 2021-01-31 08:48

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

3条回答
  •  长情又很酷
    2021-01-31 09:25

    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')
    

提交回复
热议问题