Skip to main content
deleted 30 characters in body
Source Link
adamwlev
  • 107
  • 2
  • 7

How about this:

df1 = pandas.DataFrame(data = {'col1' : [1, 2, 3, 4, 5], 'col2' : [10, 11, 12, 13, 14]}) df2 = pandas.DataFrame(data = {'col1' : [1, 2, 3], 'col2' : [10, 11, 12]}) records_df2 = set([tuple(row) for row in df2.values]) in_df2_mask = np.array([tuple(row) in records_df2  for row in df1.values]) result = df1[~in_df2_mask] 

How about this:

df1 = pandas.DataFrame(data = {'col1' : [1, 2, 3, 4, 5], 'col2' : [10, 11, 12, 13, 14]}) df2 = pandas.DataFrame(data = {'col1' : [1, 2, 3], 'col2' : [10, 11, 12]}) records_df2 = set([tuple(row) for row in df2.values]) in_df2_mask = np.array([tuple(row) in records_df2  for row in df1.values]) result = df1[~in_df2_mask] 

How about this:

df1 = pandas.DataFrame(data = {'col1' : [1, 2, 3, 4, 5], 'col2' : [10, 11, 12, 13, 14]}) df2 = pandas.DataFrame(data = {'col1' : [1, 2, 3], 'col2' : [10, 11, 12]}) records_df2 = set([tuple(row) for row in df2.values]) in_df2_mask = np.array([tuple(row) in records_df2 for row in df1.values]) result = df1[~in_df2_mask] 
Source Link
adamwlev
  • 107
  • 2
  • 7

How about this:

df1 = pandas.DataFrame(data = {'col1' : [1, 2, 3, 4, 5], 'col2' : [10, 11, 12, 13, 14]}) df2 = pandas.DataFrame(data = {'col1' : [1, 2, 3], 'col2' : [10, 11, 12]}) records_df2 = set([tuple(row) for row in df2.values]) in_df2_mask = np.array([tuple(row) in records_df2 for row in df1.values]) result = df1[~in_df2_mask]