1. From the way of merging, the merge and join are the same, there are left/right/inner/outer, and concat only has inner/outer, because the merge and join objects are merged, and the first parameter of concat It is a list of multiple dataframes. There is no strict left and right distinction. If you exclude the order of the columns in the final result, you can see it as the same. example:
Import pandas as pd
From pandas import Series, DataFrame, Panel
Df1 = DataFrame([['a','b'],['d','q'],['o','b'],['m','e']],index=[' a', 'b', 'c', 'o'], columns=['number1', 'number2'])
Df2 = DataFrame([['a','b'],['d','e'],['a','b'],['d','e']],columns=[' Col1', 'col2'], index=['f','a','g','c'])
Print pd.concat([df1,df2],join='outer',axis=1)
Print pd.concat([df2,df1],join='outer',axis=1)
2, merge merge the most extensive range, you can merge the index / column of the left object and the index / column of the right object of the four combinations; join second, can only achieve the call of the DataFrame index / column and the parameter DataFrame index merge, That is, the column of the parameter DataFrame cannot participate in the merging; the concat merges the smallest range, and only supports the merging of the index, that is, the merging of the index and the index is a common function of the three functions, for example:
Import pandas as pd
Import numpy as np
From pandas import Series, DataFrame, Panel
Df1 = DataFrame([['a','b'],['d','q'],['o','b'],['m','e']],index=[' a', 'b', 'c', 'o'], columns=['number1', 'number2'])
Df2 = DataFrame([['a','b'],['d','e'],['a','b'],['d','e']],columns=[' Col1', 'col2'], index=['f','a','g','c'])
Print(pd.merge(df1,df2,left_index=True,right_index=True,how='outer'))
Print(df1.join(df2,how='outer'))
Print(pd.concat([df1,df2],join='outer',axis=1))
It can be seen that the output of the three functions after merging the index is the same.
Number1 number2 col1 col2a a b d eb d q NaN NaNc o b d ef NaN NaN a bg NaN NaN a bo m e NaN NaN
Number1 number2 col1 col2a a b d eb d q NaN NaNc o b d ef NaN NaN a bg NaN NaN a bo m e NaN NaN
Number1 number2 col1 col2a a b d eb d q NaN NaNc o b d ef NaN NaN a bg NaN NaN a bo m e NaN NaN
3, the common point of concat and join is that you can merge more than 3 objects, merge only merges two objects
8+2 Switch And Socket,Switch And Socket,Switch Socket,Remote Control Sockets
ZHEJIANG HUAYAN ELECTRIC CO.,LTD , https://www.huayanelectric.com