title: Take two sets 'A' and 'B' , how to create a set C= A minus B in pandas
body: <p>Consider I have two sets 'A' and 'B', how do I create a set C= A minus B in pandas. Here A and B are dataframes. A is a dataframe containing First name and Last name as multiindex. B has integers as index. First name and Last name are columns in B.</p>
  
  <p>I tried by converting multindex of A to column of A by A['index']=A.index and later tried to merge B and A.But it is not working.</p>
  
  <p>A:</p>
  
  <p><img src="https://i.stack.imgur.com/I7Mzx.png" alt="csv for A.csv"></p>
  
  <p>B:</p>
  
  <p><img src="https://i.stack.imgur.com/tPhAv.png" alt="csv for B.csv"></p>
  
  <p>The columns of B (f_Name and l_name) are multiindex of A.</p>
  
  <p>I want all rows in A for which f_name and l_name does not exist in B as output. I have tried following code:</p>
  
  <pre><code>A['index']=A.index
  
  my_df=pd.merge(A,B,left_on=['F_name','L_name'],right_index=True,how='left'] 
  
  ans_df=A[~A.index.isin(my_df.index)]
  </code></pre>
  
  <p>but the len(and_df) is same as len(A) which is not correct. The length of ans_df should be less than that of A as few f_name and l_name exist in B.</p>