What is the difference between join and merge in Pandas?

后端 未结 7 2329
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 09:20

Suppose I have two DataFrames like so:

left = pd.DataFrame({\'key1\': [\'foo\', \'bar\'], \'lval\': [1, 2]})

right = pd.DataFrame({\'key2\': [\'foo\', \'bar         


        
7条回答
  •  没有蜡笔的小新
    2020-11-27 09:34

    To put it analogously to SQL "Pandas merge is to outer/inner join and Pandas join is to natural join". Hence when you use merge in pandas, you want to specify which kind of sqlish join you want to use whereas when you use pandas join, you really want to have a matching column label to ensure it joins

提交回复
热议问题