import numpy as np import pandas as pd #1.一对一 df1=pd.DataFrame({"name":["A","B","C"], "age":[30,32,33]}) df2=pd.DataFrame({"name":["A","B","C"], "tall":[310,312,313]}) print(pd.merge(df1,df2))#一对一归并 #2.一对多 df3=pd.DataFrame({"name":["A","B","C"], "type":["陕西","江西","江西"]}) df4=pd.DataFrame({"number":[1000,2000,3000], "type":["陕西","江西","广西"]}) print(pd.merge(df3,df4)) #3.多对多 df5=pd.DataFrame({"area":["north","south","north"], "type":["陕西","江西","江西"]}) print(pd.merge(df5,pd.merge(df3,df4)))