I have two dataframe as below:
df1 = DataFrame({'a': np.random.randint(10, size=2)})
df2 = DataFrame({'a': np.random.randint(10, size=100)})
There is two numbers in df1, and I want to count the two numbers' amount in df2. The answer is in the right of df1['a'].
I use for in, but there is a error:Length of values does not match length of ' 'index.
Anyone can tell me how to slove this question?
I use df2['a'].isin(df1['a']).sum(), but it give me the result that the amount of two numbers together.
I want the result like:
No Amount 8 3 1 2
instead of :
No Amount 8 5 1 5