两个df对象,要获取这两个df对象的交集和差集
取交集
inner_df = pd.merge(df1, df2, how='inner') ## 计算df1=df2的部份

left_df = pd.merge(df1, df2, how='left') ## df1部分

right_df = pd.merge(df1, df2, how='right') ## df2部分

outer_df = pd.merge(df1, df2, how='outer') ## 取合集:df1和df2所有数据的集合

取差集
利用了drop_duplicates
df1-df2
df = pd.concat([df1, df2, df2]).drop_duplicates(subset=['filed_name', 'filed_type'], keep=False)
df2-df1
df = pd.concat([df2, df1, df1]).drop_duplicates(subset=['filed_name', 'filed_type'], keep=False)

等同于
fileds_df = df1.append(df2).drop_duplicates(subset=['filed_name', 'filed_type'], keep=False)
fileds_df = df2.append(df1).drop_duplicates(subset=['filed_name', 'filed_type'], keep=False)

取df2跟df1不同的数据,采用merge指定列明进行聚合,聚合完成之后可以检查出df2中不同的数据,再查找出不同数据
merge_df = pd.merge(left=df1, right=df2, how='right', indicator=True, on=['column1','column2'])
diff_df = merge_df.loc[merge_df._merge == 'right_only', :]