Here is the problem. You are only adding ids from one dataset to corpus_ids but you are trying to remove ids from both datasets from corpus_ids on lines 


https://github.com/nikitsaraf/dedupe/blob/c6a5d01d15dc278bd7a280437c6825d543025c07/dedupe/tfidf.py#L103
https://github.com/nikitsaraf/dedupe/blob/c6a5d01d15dc278bd7a280437c6825d543025c07/dedupe/tfidf.py#L143