import numpy as np import pandas as pd #1.完全匹配 df1=pd.DataFrame({"name":["wangchenyang","guanchenhao","dongshuai"], "age":[30,32,33]}) df2=pd.DataFrame({"name":["wangchenyang","guanchenhao","dongshuai"], "tall":[310,312,313]}) print(pd.merge(df1,df2))#一对一归并 #2.不匹配 df1=pd.DataFrame({"name":["wangchenyang","guanchenhao","dongshuai"], "age":[30,32,33]}) df2=pd.DataFrame({"name":["wangchenyang","guanchenhao","guokui"], "tall":[310,312,313]}) print(pd.merge(df1,df2))#默认仅仅归并匹配的 #3. df1=pd.DataFrame({"name":["wangchenyang","guanchenhao","dongshuai"], "age":[30,32,33]}) df2=pd.DataFrame({"name":["wangchenyang","guanchenhao","guokui"], "tall":[310,312,313]}) df3=pd.DataFrame({"heavy":[100,110,130], "tall":[310,312,313]}) print(pd.merge(pd.merge(df1,df2),df3))#一一匹配 #4. df1=pd.DataFrame({"name":["wangchenyang","guanchenhao","dongshuai"], "age":[30,32,33]}) df2=pd.DataFrame({"name":["wangchenyang","guanchenhao","guokui"], "tall":[310,312,313]}) df3=pd.DataFrame({"heavy":[100,110,130], "tall":[310,312,313]}) df4=pd.DataFrame({"heavy":[100,110,130], "学历":["本科","大专","硕士"]}) print(pd.merge(pd.merge(df1,df2),pd.merge(df3,df4)))#两两匹配