python中两个数据框之间的公共记录数

时间:2020-05-26 23:28:17

标签: python dataframe

如何获取两个数据帧的通用记录数

matched_rcd = pd.merge(onprem_records,athena_rcd, indicator=False,how ='inner')

我能够获取所有匹配的记录,但是不确定如何获取匹配的记录数。

1 个答案:

答案 0 :(得分:0)

matched_rcd = pd.merge(onprem_records, athena_rcd) #to merge and get the same records only (intersection)
print(len(matched_rcd)) #to count it

交集的参考:https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf