How to compare number of occurrences in two data frames for a column and extract the similarities
EDIT: Thanks for you clarifying the question. So now the problem is checking the counts of ids in two data frames are the same.
Here is how you could go about it:
d1 = pd.DataFrame(df1[~df1['A'].isnull()].groupby(&quot;id&quot;).size())
d2 = pd.DataFrame(d[~d['A'].isnull()].groupby(&quot;id&quot;).size())

d = pd.merge(d1,d2,on=&quot;id&quot;)

ids_ = d[d[&quot;0_x&quot;] == d[&quot;0_y&quot;]].index.values

RETURN:
array([1, 3])

This will now give an array of ids where the counts in both df1 and d are the same.