def test_drop_duplicate_index(self, mock_index): comparable = Compare() comparable.index_column_name = mock_index d = {'id': ['dup1', 'dup1', 'dup1', 'AAA', 'BBB']} dup = {'id': ['dup1', 'dup1', 'dup1']} comparable.data_frame = pd.DataFrame(data=d, dtype="object") comparable.duplicate_index = pd.DataFrame(data=dup, dtype="object") index_validator.drop_duplicate_index(comparable) expected = ['AAA', 'BBB'] actual = list(comparable.data_frame['id'].values) assert expected == actual
def check_for_duplicate_index(comparable: Compare): index_name = idx.get_index_name(comparable) comparable.duplicate_index = comparable.data_frame[ comparable.data_frame.duplicated([index_name], keep=False)]