File size: 153,834 Bytes
6ef14cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We explored the error file in `EDA-DL-0-1.ipynb` and saved a CSV of the failed download records, as it was not clear how we could potentially find those images from their Zenodo records (they didn't seem to be present in the records whose metadata listed them). There seem to be only 23 specimens that were not otherwise represented in our download.\n",
    "\n",
    "## Explore Downloaded Images\n",
    "\n",
    "We'll do an inner merge on the master file and checksums to get a master downloadable file, which will be further reduced to just unique images."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(42143, 3)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "checksums = pd.read_csv(\"../metadata/deduplication/Jiggins_Zenodo_Img_Master_3477891Patch_checksums.csv\", low_memory=False)\n",
    "checksums.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "filepath    42143\n",
       "filename    42143\n",
       "md5         36212\n",
       "dtype: int64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "checksums.nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difference between these is the number of unique Image names among the duplicated images. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(44809, 28)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master = pd.read_csv(\"../metadata/Jiggins_Zenodo_Img_Master_3477891Patch.csv\", low_memory = False)\n",
    "master.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`filename` in `checksums` is `<X>_<Image_name>`, so we'll create such a `filename` column in `master` to merge the two DataFrames on."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID               11991\n",
       "X                   44809\n",
       "Image_name          36281\n",
       "View                    7\n",
       "zenodo_name            33\n",
       "zenodo_link            30\n",
       "Sequence            10905\n",
       "Taxonomic_Name        366\n",
       "Locality              645\n",
       "Sample_accession     1559\n",
       "Collected_by           12\n",
       "Other_ID             3081\n",
       "Date                  807\n",
       "Dataset                 8\n",
       "Store                 137\n",
       "Brood                 224\n",
       "Death_Date             81\n",
       "Cross_Type             30\n",
       "Stage                   1\n",
       "Sex                     3\n",
       "Unit_Type               4\n",
       "file_type               3\n",
       "record_number          30\n",
       "species               246\n",
       "subspecies            155\n",
       "genus                  94\n",
       "file_url            39297\n",
       "hybrid_stat             2\n",
       "filename            44809\n",
       "dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master[\"filename\"] = master[\"X\"].astype(str) + \"_\" + master[\"Image_name\"]\n",
    "master.nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Our number of unique downloaded images is 69 less than the number of unique values of `Image_name`. For reference, we recorded 612 unique `CAMID`s in our error log of 2666 images that could not be downloaded.\n",
    "\n",
    "### Merge `master` and `checksums`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(42143, 31)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master_checksums = pd.merge(master,\n",
    "                            checksums,\n",
    "                            on = \"filename\",\n",
    "                            how = \"inner\")\n",
    "# Expectation is 42143 entries now\n",
    "master_checksums.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID         11968\n",
       "Image_name    36216\n",
       "X             42143\n",
       "filename      42143\n",
       "md5           36212\n",
       "file_url      36631\n",
       "dtype: int64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id_cols = [\"CAMID\", \"Image_name\", \"X\", \"filename\", \"md5\", \"file_url\"]\n",
    "master_checksums[id_cols].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "23 CAMIDs lost, as expected from the error evaluation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Did we lose any of our diversity? Taxonomic, image view, source (dataset or location of butterfly), etc. Only one stage is indicated in full master file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Taxonomic_Name    366\n",
       "species           246\n",
       "subspecies        155\n",
       "genus              94\n",
       "Cross_Type         30\n",
       "View                7\n",
       "Locality          644\n",
       "Sex                 3\n",
       "Dataset             7\n",
       "dtype: int64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stats_cols = [\"Taxonomic_Name\", \"species\", \"subspecies\", \"genus\", \"Cross_Type\", \"View\", \"Locality\", \"Sex\", \"Dataset\"]\n",
    "\n",
    "master_checksums[stats_cols].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We lost one location and one dataset source to unsuccessful downloads.\n",
    "\n",
    "#### Check on Lost Representation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24204    Huaymayaco\n",
       "Name: Locality, dtype: object"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master.loc[~master[\"Locality\"].isin(list(master_checksums[\"Locality\"].unique())), \"Locality\"].sample()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24233    Cambridge Collection\n",
       "Name: Dataset, dtype: object"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master.loc[~master[\"Dataset\"].isin(list(master_checksums[\"Dataset\"].unique())), \"Dataset\"].sample()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 47 entries, 24194 to 24240\n",
      "Data columns (total 29 columns):\n",
      " #   Column            Non-Null Count  Dtype \n",
      "---  ------            --------------  ----- \n",
      " 0   CAMID             47 non-null     object\n",
      " 1   X                 47 non-null     int64 \n",
      " 2   Image_name        47 non-null     object\n",
      " 3   View              47 non-null     object\n",
      " 4   zenodo_name       47 non-null     object\n",
      " 5   zenodo_link       47 non-null     object\n",
      " 6   Sequence          47 non-null     object\n",
      " 7   Taxonomic_Name    47 non-null     object\n",
      " 8   Locality          47 non-null     object\n",
      " 9   Sample_accession  0 non-null      object\n",
      " 10  Collected_by      0 non-null      object\n",
      " 11  Other_ID          0 non-null      object\n",
      " 12  Date              47 non-null     object\n",
      " 13  Dataset           47 non-null     object\n",
      " 14  Store             0 non-null      object\n",
      " 15  Brood             0 non-null      object\n",
      " 16  Death_Date        47 non-null     object\n",
      " 17  Cross_Type        0 non-null      object\n",
      " 18  Stage             0 non-null      object\n",
      " 19  Sex               47 non-null     object\n",
      " 20  Unit_Type         47 non-null     object\n",
      " 21  file_type         47 non-null     object\n",
      " 22  record_number     47 non-null     int64 \n",
      " 23  species           47 non-null     object\n",
      " 24  subspecies        47 non-null     object\n",
      " 25  genus             47 non-null     object\n",
      " 26  file_url          47 non-null     object\n",
      " 27  hybrid_stat       47 non-null     object\n",
      " 28  filename          47 non-null     object\n",
      "dtypes: int64(2), object(27)\n",
      "memory usage: 11.0+ KB\n"
     ]
    }
   ],
   "source": [
    "missing_samples = master.loc[(master[\"Locality\"] == \"Huaymayaco\") | (master[\"Dataset\"] == \"Cambridge Collection\")] \n",
    "missing_samples.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "record_number\n",
       "4289223    47\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "missing_samples.record_number.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This record ([4289223](https://zenodo.org/records/4289223)) was examined in `EDA-DL-0-2.ipynb`. The images were listed in the provided metadata file for that record, but they did not appear in the record itself.\n",
    "They are the majority of the images from Rachel Blow's Ecuador collection 2018 melpomene and timareta, near ikiam (taken in October 2019), listed in [0.2.rachel.blow.mel.tim.ikiam.csv](https://zenodo.org/records/4289223/preview/0.2.rachel.blow.mel.tim.ikiam.csv?include_deleted=0)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Explore Downloaded Images\n",
    "\n",
    "We have approximately 6000 duplicated images. We need to explore the information associated with each and reduce down to just unique images."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Are CAMIDs consistent in naming that duplicate images share CAMID (in same format)?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(11858, 32)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "CAMID                2815\n",
       "X                   11858\n",
       "Image_name           5931\n",
       "View                    2\n",
       "zenodo_name            15\n",
       "zenodo_link            15\n",
       "Sequence             2815\n",
       "Taxonomic_Name        195\n",
       "Locality              210\n",
       "Sample_accession      446\n",
       "Collected_by            0\n",
       "Other_ID              106\n",
       "Date                  200\n",
       "Dataset                 1\n",
       "Store                  58\n",
       "Brood                   9\n",
       "Death_Date              0\n",
       "Cross_Type              0\n",
       "Stage                   0\n",
       "Sex                     3\n",
       "Unit_Type               3\n",
       "file_type               3\n",
       "record_number          15\n",
       "species               121\n",
       "subspecies             93\n",
       "genus                  38\n",
       "file_url             6346\n",
       "hybrid_stat             2\n",
       "filename            11858\n",
       "filepath            11858\n",
       "md5                  5927\n",
       "duplicate_md5           1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master_checksums[\"duplicate_md5\"] = master_checksums.duplicated(\"md5\", keep = False)\n",
    "duplicated_images = master_checksums.loc[master_checksums[\"duplicate_md5\"]]\n",
    "\n",
    "print(duplicated_images.shape)\n",
    "duplicated_images.nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Observations:\n",
    "- Half of the Zenodo records wind up with duplicated images. \n",
    "- `Image_name` uniqueness is close to `md5`, but there are 4 more unique image names than unique images. \n",
    "- None of the cross types are duplicated.\n",
    "- We do have multiple unique images for a single `CAMID`, more than just dorsal vs ventral since there are 2815 unique CAMIDs and 5927 unique `md5` values (5927 = 2x2815 + 297)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Save master file of all downloaded images with MD5s (no duplicate marker)\n",
    "master_checksums[list(master_checksums.columns)[:-1]].to_csv(\"../metadata/deduplication/Jiggins_Zenodo_Img_Master_3477891Patch_downloaded.csv\", index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9212"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master_checksums.loc[~master_checksums[\"duplicate_md5\"], \"CAMID\"].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['CAMID',\n",
       " 'X',\n",
       " 'Image_name',\n",
       " 'View',\n",
       " 'zenodo_name',\n",
       " 'zenodo_link',\n",
       " 'Sequence',\n",
       " 'Taxonomic_Name',\n",
       " 'Locality',\n",
       " 'Sample_accession',\n",
       " 'Other_ID',\n",
       " 'Date',\n",
       " 'Dataset',\n",
       " 'Store',\n",
       " 'Brood',\n",
       " 'Sex',\n",
       " 'Unit_Type',\n",
       " 'file_type',\n",
       " 'record_number',\n",
       " 'species',\n",
       " 'subspecies',\n",
       " 'genus',\n",
       " 'file_url',\n",
       " 'hybrid_stat',\n",
       " 'filename',\n",
       " 'filepath',\n",
       " 'md5',\n",
       " 'duplicate_md5']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "non_null_cols = [col for col in list(duplicated_images.columns) if duplicated_images.loc[duplicated_images[col].notna()].shape[0] > 0]\n",
    "non_null_cols"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's remove all the columns with null values for easier analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 11858 entries, 3233 to 40186\n",
      "Data columns (total 28 columns):\n",
      " #   Column            Non-Null Count  Dtype \n",
      "---  ------            --------------  ----- \n",
      " 0   CAMID             11858 non-null  object\n",
      " 1   X                 11858 non-null  int64 \n",
      " 2   Image_name        11858 non-null  object\n",
      " 3   View              11858 non-null  object\n",
      " 4   zenodo_name       11858 non-null  object\n",
      " 5   zenodo_link       11858 non-null  object\n",
      " 6   Sequence          11858 non-null  object\n",
      " 7   Taxonomic_Name    11858 non-null  object\n",
      " 8   Locality          11836 non-null  object\n",
      " 9   Sample_accession  1846 non-null   object\n",
      " 10  Other_ID          830 non-null    object\n",
      " 11  Date              10046 non-null  object\n",
      " 12  Dataset           11614 non-null  object\n",
      " 13  Store             11670 non-null  object\n",
      " 14  Brood             808 non-null    object\n",
      " 15  Sex               11474 non-null  object\n",
      " 16  Unit_Type         11614 non-null  object\n",
      " 17  file_type         11858 non-null  object\n",
      " 18  record_number     11858 non-null  int64 \n",
      " 19  species           11858 non-null  object\n",
      " 20  subspecies        8200 non-null   object\n",
      " 21  genus             11858 non-null  object\n",
      " 22  file_url          11858 non-null  object\n",
      " 23  hybrid_stat       8264 non-null   object\n",
      " 24  filename          11858 non-null  object\n",
      " 25  filepath          11858 non-null  object\n",
      " 26  md5               11858 non-null  object\n",
      " 27  duplicate_md5     11858 non-null  bool  \n",
      "dtypes: bool(1), int64(2), object(25)\n",
      "memory usage: 2.5+ MB\n"
     ]
    }
   ],
   "source": [
    "duplicated_images = duplicated_images[non_null_cols]\n",
    "duplicated_images.info(show_counts=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is some inconsistency with label coverage, which is hopefully resolvable for duplciated images."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "record_number\n",
       "3477891    5501\n",
       "2707828    1276\n",
       "2714333    1113\n",
       "2686762     980\n",
       "2684906     747\n",
       "2677821     703\n",
       "2813153     435\n",
       "4291095     415\n",
       "2702457     260\n",
       "2682458     148\n",
       "2682669      92\n",
       "2552371      91\n",
       "2550097      50\n",
       "2553977      27\n",
       "5526257      20\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicated_images.record_number.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is mostly record 3477891 and the number of duplicate images in record 3477891 (5501) matches with the number of images that were matched to the multimedia CSV from that record to do the download patch. If I remove all instances of record 3477891, will we still have duplicates and will we have the same number of unique images?\n",
    "\n",
    "### Check without Record 3477891"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "36642\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "CAMID         11968\n",
       "Image_name    36216\n",
       "X             36642\n",
       "filename      36642\n",
       "md5           36212\n",
       "file_url      36631\n",
       "dtype: int64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "no_patch = master_checksums.loc[master_checksums[\"record_number\"] != 3477891]\n",
    "\n",
    "print(no_patch.shape[0])\n",
    "no_patch[id_cols].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Yes, removing that record gives us the same number of unique images. ID Stats are consistent (unique MD5s and CAMIDs).\n",
    "\n",
    "We have 430 images that are duplicates (`X - md5`)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Would keeping it allow us to remove others?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID          2704\n",
       "Image_name     5497\n",
       "X             10998\n",
       "filename      10998\n",
       "md5            5497\n",
       "file_url       5497\n",
       "dtype: int64"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_3477891_urls = list(master_checksums.loc[master_checksums[\"record_number\"] == 3477891, \"file_url\"].unique())\n",
    "\n",
    "rec_3477891_images = master_checksums.loc[master_checksums[\"file_url\"].isin(rec_3477891_urls)]\n",
    "\n",
    "rec_3477891_images[id_cols].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "record_number\n",
       "3477891    5501\n",
       "2707828    1276\n",
       "2714333    1113\n",
       "2686762     980\n",
       "2684906     747\n",
       "2677821     703\n",
       "2702457     260\n",
       "2682458     148\n",
       "2682669      92\n",
       "2552371      89\n",
       "2550097      50\n",
       "2813153      20\n",
       "2553977      19\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_3477891_images.record_number.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2677821\n",
      "X           769\n",
      "CAMID       387\n",
      "md5         769\n",
      "file_url    769\n",
      "dtype: int64\n",
      "\n",
      "3477891\n",
      "X           5501\n",
      "CAMID       2704\n",
      "md5         5497\n",
      "file_url    5497\n",
      "dtype: int64\n",
      "\n",
      "2682458\n",
      "X           950\n",
      "CAMID       476\n",
      "md5         950\n",
      "file_url    950\n",
      "dtype: int64\n",
      "\n",
      "2682669\n",
      "X           915\n",
      "CAMID       458\n",
      "md5         915\n",
      "file_url    915\n",
      "dtype: int64\n",
      "\n",
      "2684906\n",
      "X           977\n",
      "CAMID       492\n",
      "md5         977\n",
      "file_url    977\n",
      "dtype: int64\n",
      "\n",
      "2552371\n",
      "X           2392\n",
      "CAMID       1189\n",
      "md5         2391\n",
      "file_url    2392\n",
      "dtype: int64\n",
      "\n",
      "2553977\n",
      "X           158\n",
      "CAMID        79\n",
      "md5         154\n",
      "file_url    157\n",
      "dtype: int64\n",
      "\n",
      "2686762\n",
      "X           1384\n",
      "CAMID        694\n",
      "md5         1384\n",
      "file_url    1384\n",
      "dtype: int64\n",
      "\n",
      "2550097\n",
      "X           1400\n",
      "CAMID        351\n",
      "md5         1400\n",
      "file_url    1400\n",
      "dtype: int64\n",
      "\n",
      "2702457\n",
      "X           771\n",
      "CAMID       388\n",
      "md5         771\n",
      "file_url    771\n",
      "dtype: int64\n",
      "\n",
      "2813153\n",
      "X           523\n",
      "CAMID       158\n",
      "md5         523\n",
      "file_url    523\n",
      "dtype: int64\n",
      "\n",
      "2707828\n",
      "X           1292\n",
      "CAMID        646\n",
      "md5         1292\n",
      "file_url    1292\n",
      "dtype: int64\n",
      "\n",
      "2714333\n",
      "X           1356\n",
      "CAMID        647\n",
      "md5         1356\n",
      "file_url    1356\n",
      "dtype: int64\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for record in list(rec_3477891_images.record_number.unique()):\n",
    "    print(record)\n",
    "    temp = master_checksums.loc[master_checksums[\"record_number\"] == record]\n",
    "    print(temp[[\"X\",\"CAMID\", \"md5\", \"file_url\"]].nunique())\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Definitely cleaner to just remove record 3477891."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4289223\n",
      "X           145\n",
      "CAMID        73\n",
      "md5         145\n",
      "file_url    145\n",
      "dtype: int64\n",
      "\n",
      "4288311\n",
      "X           3088\n",
      "CAMID       1050\n",
      "md5         3088\n",
      "file_url    3088\n",
      "dtype: int64\n",
      "\n",
      "2677821\n",
      "X           769\n",
      "CAMID       387\n",
      "md5         769\n",
      "file_url    769\n",
      "dtype: int64\n",
      "\n",
      "2682458\n",
      "X           950\n",
      "CAMID       476\n",
      "md5         950\n",
      "file_url    950\n",
      "dtype: int64\n",
      "\n",
      "2682669\n",
      "X           915\n",
      "CAMID       458\n",
      "md5         915\n",
      "file_url    915\n",
      "dtype: int64\n",
      "\n",
      "2684906\n",
      "X           977\n",
      "CAMID       492\n",
      "md5         977\n",
      "file_url    977\n",
      "dtype: int64\n",
      "\n",
      "2552371\n",
      "X           2392\n",
      "CAMID       1189\n",
      "md5         2391\n",
      "file_url    2392\n",
      "dtype: int64\n",
      "\n",
      "2553977\n",
      "X           158\n",
      "CAMID        79\n",
      "md5         154\n",
      "file_url    157\n",
      "dtype: int64\n",
      "\n",
      "2686762\n",
      "X           1384\n",
      "CAMID        694\n",
      "md5         1384\n",
      "file_url    1384\n",
      "dtype: int64\n",
      "\n",
      "2549524\n",
      "X           1471\n",
      "CAMID        368\n",
      "md5         1471\n",
      "file_url    1471\n",
      "dtype: int64\n",
      "\n",
      "2550097\n",
      "X           1400\n",
      "CAMID        351\n",
      "md5         1400\n",
      "file_url    1400\n",
      "dtype: int64\n",
      "\n",
      "4153502\n",
      "X           583\n",
      "CAMID       147\n",
      "md5         583\n",
      "file_url    583\n",
      "dtype: int64\n",
      "\n",
      "3082688\n",
      "X           2917\n",
      "CAMID       1467\n",
      "md5         2917\n",
      "file_url    2917\n",
      "dtype: int64\n",
      "\n",
      "2813153\n",
      "X           523\n",
      "CAMID       158\n",
      "md5         523\n",
      "file_url    523\n",
      "dtype: int64\n",
      "\n",
      "1748277\n",
      "X           1992\n",
      "CAMID        499\n",
      "md5         1992\n",
      "file_url    1992\n",
      "dtype: int64\n",
      "\n",
      "2702457\n",
      "X           771\n",
      "CAMID       388\n",
      "md5         771\n",
      "file_url    771\n",
      "dtype: int64\n",
      "\n",
      "2548678\n",
      "X           1298\n",
      "CAMID        325\n",
      "md5         1298\n",
      "file_url    1298\n",
      "dtype: int64\n",
      "\n",
      "5561246\n",
      "X           1478\n",
      "CAMID        371\n",
      "md5         1478\n",
      "file_url    1478\n",
      "dtype: int64\n",
      "\n",
      "2707828\n",
      "X           1292\n",
      "CAMID        646\n",
      "md5         1292\n",
      "file_url    1292\n",
      "dtype: int64\n",
      "\n",
      "2714333\n",
      "X           1356\n",
      "CAMID        647\n",
      "md5         1356\n",
      "file_url    1356\n",
      "dtype: int64\n",
      "\n",
      "4291095\n",
      "X           2212\n",
      "CAMID        553\n",
      "md5         2212\n",
      "file_url    2212\n",
      "dtype: int64\n",
      "\n",
      "3569598\n",
      "X           1618\n",
      "CAMID        377\n",
      "md5         1618\n",
      "file_url    1618\n",
      "dtype: int64\n",
      "\n",
      "4287444\n",
      "X           1188\n",
      "CAMID        269\n",
      "md5         1188\n",
      "file_url    1188\n",
      "dtype: int64\n",
      "\n",
      "4288250\n",
      "X           2593\n",
      "CAMID        579\n",
      "md5         2593\n",
      "file_url    2593\n",
      "dtype: int64\n",
      "\n",
      "5526257\n",
      "X           1324\n",
      "CAMID        330\n",
      "md5         1314\n",
      "file_url    1314\n",
      "dtype: int64\n",
      "\n",
      "2553501\n",
      "X           464\n",
      "CAMID       232\n",
      "md5         464\n",
      "file_url    464\n",
      "dtype: int64\n",
      "\n",
      "2735056\n",
      "X           452\n",
      "CAMID       113\n",
      "md5         452\n",
      "file_url    452\n",
      "dtype: int64\n",
      "\n",
      "2554218\n",
      "X           492\n",
      "CAMID       123\n",
      "md5         492\n",
      "file_url    492\n",
      "dtype: int64\n",
      "\n",
      "2555086\n",
      "X           440\n",
      "CAMID       110\n",
      "md5         440\n",
      "file_url    440\n",
      "dtype: int64\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for record in list(no_patch.record_number.unique()):\n",
    "    print(record)\n",
    "    temp = no_patch.loc[no_patch[\"record_number\"] == record]\n",
    "    print(temp[[\"X\",\"CAMID\", \"md5\", \"file_url\"]].nunique())\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Two records have a few duplicate images within them (record 2552371 has 1 and record 2553977 has 3)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_74270/343859278.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  no_patch[\"duplicate_md5\"] = no_patch.duplicated(\"md5\", keep = False)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "duplicate_md5\n",
       "False    35782\n",
       "True       860\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "no_patch[\"duplicate_md5\"] = no_patch.duplicated(\"md5\", keep = False)\n",
    "no_patch[\"duplicate_md5\"].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Yes, we still have duplicates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID         11864\n",
       "Image_name    35782\n",
       "X             35782\n",
       "filename      35782\n",
       "md5           35782\n",
       "file_url      35782\n",
       "dtype: int64"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "non_dupes = no_patch.loc[~no_patch[\"duplicate_md5\"]]\n",
    "non_dupes[id_cols].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "View\n",
       "dorsal                17019\n",
       "ventral               16954\n",
       "hindwing dorsal         254\n",
       "hindwing ventral        254\n",
       "forewing dorsal         252\n",
       "forewing ventral        252\n",
       "dorsal and ventral       18\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "non_dupes.View.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "file_type\n",
       "jpg    25618\n",
       "raw    10111\n",
       "tif       53\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "non_dupes.file_type.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "View\n",
       "dorsal                12405\n",
       "ventral               12342\n",
       "hindwing dorsal         127\n",
       "hindwing ventral        127\n",
       "forewing dorsal         126\n",
       "forewing ventral        126\n",
       "dorsal and ventral       18\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "non_dupes.loc[non_dupes[\"file_type\"] != \"raw\", \"View\"].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So among our non-duplicated images we do see multiple images of the same specimen after accounting for file type and view of the specimen (as determined by the number of ventral or dorsal images)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Explore the duplicates\n",
    "Ensure that we maintain all the available metadata associated with the images as we remove duplicates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 860 entries, 11978 to 40145\n",
      "Data columns (total 28 columns):\n",
      " #   Column            Non-Null Count  Dtype \n",
      "---  ------            --------------  ----- \n",
      " 0   CAMID             860 non-null    object\n",
      " 1   X                 860 non-null    int64 \n",
      " 2   Image_name        860 non-null    object\n",
      " 3   View              860 non-null    object\n",
      " 4   zenodo_name       860 non-null    object\n",
      " 5   zenodo_link       860 non-null    object\n",
      " 6   Sequence          860 non-null    object\n",
      " 7   Taxonomic_Name    860 non-null    object\n",
      " 8   Locality          838 non-null    object\n",
      " 9   Sample_accession  0 non-null      object\n",
      " 10  Other_ID          806 non-null    object\n",
      " 11  Date              0 non-null      object\n",
      " 12  Dataset           616 non-null    object\n",
      " 13  Store             832 non-null    object\n",
      " 14  Brood             800 non-null    object\n",
      " 15  Sex               608 non-null    object\n",
      " 16  Unit_Type         616 non-null    object\n",
      " 17  file_type         860 non-null    object\n",
      " 18  record_number     860 non-null    int64 \n",
      " 19  species           860 non-null    object\n",
      " 20  subspecies        858 non-null    object\n",
      " 21  genus             860 non-null    object\n",
      " 22  file_url          860 non-null    object\n",
      " 23  hybrid_stat       858 non-null    object\n",
      " 24  filename          860 non-null    object\n",
      " 25  filepath          860 non-null    object\n",
      " 26  md5               860 non-null    object\n",
      " 27  duplicate_md5     860 non-null    bool  \n",
      "dtypes: bool(1), int64(2), object(25)\n",
      "memory usage: 189.0+ KB\n"
     ]
    }
   ],
   "source": [
    "no_patch_duplicates = no_patch.loc[no_patch[\"duplicate_md5\"]]\n",
    "\n",
    "no_patch_duplicates[non_null_cols].info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A couple more nulls were introduced."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID         111\n",
       "Image_name    434\n",
       "X             860\n",
       "filename      860\n",
       "md5           430\n",
       "file_url      849\n",
       "dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "no_patch_duplicates[id_cols].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Taxonomic_Name    4\n",
       "species           3\n",
       "subspecies        3\n",
       "genus             1\n",
       "Cross_Type        0\n",
       "View              2\n",
       "Locality          6\n",
       "Sex               2\n",
       "Dataset           1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "no_patch_duplicates[stats_cols].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "record_number\n",
       "4291095    415\n",
       "2813153    415\n",
       "5526257     20\n",
       "2553977      8\n",
       "2552371      2\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "no_patch_duplicates.record_number.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looks like we just have two of each image.\n",
    "\n",
    "I'd hazard a guess that records [4291095](https://zenodo.org/records/4291095) and [2813153](https://zenodo.org/records/2813153) are duplicates of each other and contain some of the images from the others (as there are 430 unique images).\n",
    "\n",
    "based on their descriptions (on Zenodo) it doesn't seem like they should have any overlap..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CAMID</th>\n",
       "      <th>X</th>\n",
       "      <th>Image_name</th>\n",
       "      <th>View</th>\n",
       "      <th>zenodo_name</th>\n",
       "      <th>zenodo_link</th>\n",
       "      <th>Sequence</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>Locality</th>\n",
       "      <th>Sample_accession</th>\n",
       "      <th>...</th>\n",
       "      <th>record_number</th>\n",
       "      <th>species</th>\n",
       "      <th>subspecies</th>\n",
       "      <th>genus</th>\n",
       "      <th>file_url</th>\n",
       "      <th>hybrid_stat</th>\n",
       "      <th>filename</th>\n",
       "      <th>filepath</th>\n",
       "      <th>md5</th>\n",
       "      <th>duplicate_md5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>32499</th>\n",
       "      <td>CAM041807</td>\n",
       "      <td>40194</td>\n",
       "      <td>CAM041807_d.CR2</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,807</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40194_CAM041807_d.CR2</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40194_C...</td>\n",
       "      <td>1ef3dbe7b286a34882d21ef39424f18a</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32502</th>\n",
       "      <td>CAM041807</td>\n",
       "      <td>40197</td>\n",
       "      <td>CAM041807_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,807</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40197_CAM041807_v.JPG</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40197_C...</td>\n",
       "      <td>844f9b09adda5d919694a8c1a38ca991</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32504</th>\n",
       "      <td>CAM041807</td>\n",
       "      <td>40195</td>\n",
       "      <td>CAM041807_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,807</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40195_CAM041807_d.JPG</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40195_C...</td>\n",
       "      <td>1e77684537bc187b8e82b0f9f4342275</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32505</th>\n",
       "      <td>CAM041807</td>\n",
       "      <td>40196</td>\n",
       "      <td>CAM041807_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,807</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40196_CAM041807_v.CR2</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40196_C...</td>\n",
       "      <td>b1daeb529e16952906c986d193bcc32d</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32507</th>\n",
       "      <td>CAM041808</td>\n",
       "      <td>40198</td>\n",
       "      <td>CAM041808_d.CR2</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,808</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40198_CAM041808_d.CR2</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40198_C...</td>\n",
       "      <td>e1b16f08005517abfda5ef098b11b8b1</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32511</th>\n",
       "      <td>CAM041808</td>\n",
       "      <td>40201</td>\n",
       "      <td>CAM041808_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,808</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40201_CAM041808_v.JPG</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40201_C...</td>\n",
       "      <td>3325bc1d4bf98f1b49a7f9b1580cbf8d</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32512</th>\n",
       "      <td>CAM041808</td>\n",
       "      <td>40199</td>\n",
       "      <td>CAM041808_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,808</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40199_CAM041808_d.JPG</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40199_C...</td>\n",
       "      <td>5498918119fbcbdf714d3f31388336a2</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32513</th>\n",
       "      <td>CAM041808</td>\n",
       "      <td>40200</td>\n",
       "      <td>CAM041808_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,808</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40200_CAM041808_v.CR2</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40200_C...</td>\n",
       "      <td>241d924503c32d33c44d0e6863da4d9c</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32517</th>\n",
       "      <td>CAM041809</td>\n",
       "      <td>40203</td>\n",
       "      <td>CAM041809_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,809</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40203_CAM041809_d.JPG</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40203_C...</td>\n",
       "      <td>6ab1ecd5eaf4b38bbe441565bc8b87ab</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32518</th>\n",
       "      <td>CAM041809</td>\n",
       "      <td>40205</td>\n",
       "      <td>CAM041809_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "      <td>41,809</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>Ikiam Mariposario</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>4291095</td>\n",
       "      <td>Heliconius erato</td>\n",
       "      <td>lativitta</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/4291095/files/CAM041...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>40205_CAM041809_v.JPG</td>\n",
       "      <td>images/Heliconius erato ssp. lativitta/40205_C...</td>\n",
       "      <td>78508c7ea9cf973b2d3dfe4d91fc11f1</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 32 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID      X       Image_name     View           zenodo_name  \\\n",
       "32499  CAM041807  40194  CAM041807_d.CR2   dorsal  0.gmk.broods.all.csv   \n",
       "32502  CAM041807  40197  CAM041807_v.JPG  ventral  0.gmk.broods.all.csv   \n",
       "32504  CAM041807  40195  CAM041807_d.JPG   dorsal  0.gmk.broods.all.csv   \n",
       "32505  CAM041807  40196  CAM041807_v.CR2  ventral  0.gmk.broods.all.csv   \n",
       "32507  CAM041808  40198  CAM041808_d.CR2   dorsal  0.gmk.broods.all.csv   \n",
       "32511  CAM041808  40201  CAM041808_v.JPG  ventral  0.gmk.broods.all.csv   \n",
       "32512  CAM041808  40199  CAM041808_d.JPG   dorsal  0.gmk.broods.all.csv   \n",
       "32513  CAM041808  40200  CAM041808_v.CR2  ventral  0.gmk.broods.all.csv   \n",
       "32517  CAM041809  40203  CAM041809_d.JPG   dorsal  0.gmk.broods.all.csv   \n",
       "32518  CAM041809  40205  CAM041809_v.JPG  ventral  0.gmk.broods.all.csv   \n",
       "\n",
       "                             zenodo_link Sequence  \\\n",
       "32499  https://zenodo.org/record/4291095   41,807   \n",
       "32502  https://zenodo.org/record/4291095   41,807   \n",
       "32504  https://zenodo.org/record/4291095   41,807   \n",
       "32505  https://zenodo.org/record/4291095   41,807   \n",
       "32507  https://zenodo.org/record/4291095   41,808   \n",
       "32511  https://zenodo.org/record/4291095   41,808   \n",
       "32512  https://zenodo.org/record/4291095   41,808   \n",
       "32513  https://zenodo.org/record/4291095   41,808   \n",
       "32517  https://zenodo.org/record/4291095   41,809   \n",
       "32518  https://zenodo.org/record/4291095   41,809   \n",
       "\n",
       "                        Taxonomic_Name           Locality Sample_accession  \\\n",
       "32499  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32502  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32504  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32505  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32507  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32511  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32512  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32513  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32517  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "32518  Heliconius erato ssp. lativitta  Ikiam Mariposario              NaN   \n",
       "\n",
       "       ... record_number           species subspecies       genus  \\\n",
       "32499  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32502  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32504  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32505  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32507  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32511  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32512  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32513  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32517  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "32518  ...       4291095  Heliconius erato  lativitta  Heliconius   \n",
       "\n",
       "                                                file_url hybrid_stat  \\\n",
       "32499  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32502  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32504  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32505  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32507  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32511  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32512  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32513  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32517  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "32518  https://zenodo.org/record/4291095/files/CAM041...  non-hybrid   \n",
       "\n",
       "                    filename  \\\n",
       "32499  40194_CAM041807_d.CR2   \n",
       "32502  40197_CAM041807_v.JPG   \n",
       "32504  40195_CAM041807_d.JPG   \n",
       "32505  40196_CAM041807_v.CR2   \n",
       "32507  40198_CAM041808_d.CR2   \n",
       "32511  40201_CAM041808_v.JPG   \n",
       "32512  40199_CAM041808_d.JPG   \n",
       "32513  40200_CAM041808_v.CR2   \n",
       "32517  40203_CAM041809_d.JPG   \n",
       "32518  40205_CAM041809_v.JPG   \n",
       "\n",
       "                                                filepath  \\\n",
       "32499  images/Heliconius erato ssp. lativitta/40194_C...   \n",
       "32502  images/Heliconius erato ssp. lativitta/40197_C...   \n",
       "32504  images/Heliconius erato ssp. lativitta/40195_C...   \n",
       "32505  images/Heliconius erato ssp. lativitta/40196_C...   \n",
       "32507  images/Heliconius erato ssp. lativitta/40198_C...   \n",
       "32511  images/Heliconius erato ssp. lativitta/40201_C...   \n",
       "32512  images/Heliconius erato ssp. lativitta/40199_C...   \n",
       "32513  images/Heliconius erato ssp. lativitta/40200_C...   \n",
       "32517  images/Heliconius erato ssp. lativitta/40203_C...   \n",
       "32518  images/Heliconius erato ssp. lativitta/40205_C...   \n",
       "\n",
       "                                    md5 duplicate_md5  \n",
       "32499  1ef3dbe7b286a34882d21ef39424f18a          True  \n",
       "32502  844f9b09adda5d919694a8c1a38ca991          True  \n",
       "32504  1e77684537bc187b8e82b0f9f4342275          True  \n",
       "32505  b1daeb529e16952906c986d193bcc32d          True  \n",
       "32507  e1b16f08005517abfda5ef098b11b8b1          True  \n",
       "32511  3325bc1d4bf98f1b49a7f9b1580cbf8d          True  \n",
       "32512  5498918119fbcbdf714d3f31388336a2          True  \n",
       "32513  241d924503c32d33c44d0e6863da4d9c          True  \n",
       "32517  6ab1ecd5eaf4b38bbe441565bc8b87ab          True  \n",
       "32518  78508c7ea9cf973b2d3dfe4d91fc11f1          True  \n",
       "\n",
       "[10 rows x 32 columns]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"] == 4291095].head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_74270/3053018095.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  rec_4291095[\"dupes\"] = rec_4291095.duplicated(\"md5\")\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "dupes\n",
       "False    415\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_4291095 = no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"] == 4291095]\n",
    "rec_4291095[\"dupes\"] = rec_4291095.duplicated(\"md5\")\n",
    "rec_4291095[\"dupes\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "415"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"].isin([4291095, 2813153]), \"md5\"].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These shouldn't be duplicates based on their Zenodo descriptions. Let's download their CSV files and check the metadata matches."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_4291095 = pd.read_csv(\"../metadata/deduplication/Zenodo_meta_files/0.gmk.broods.all_(rec4291095).csv\", low_memory=False)\n",
    "df_2813153 = pd.read_csv(\"../metadata/deduplication/Zenodo_meta_files/CAM.coll.images.batch10_(rec2813153).csv\", low_memory=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2220, 591)"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_4291095.shape[0], df_2813153.shape[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "record_number\n",
       "4291095    2212\n",
       "2813153     523\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "master_checksums.loc[master_checksums[\"record_number\"].isin([4291095, 2813153]), \"record_number\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['image.name', 'unit.id', 'side'], dtype='object')"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_4291095.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2212"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_4291095_check = pd.merge(master_checksums.loc[master_checksums[\"record_number\"] == 4291095],\n",
    "                             df_4291095,\n",
    "                             left_on = \"Image_name\",\n",
    "                             right_on = \"image.name\",\n",
    "                             how = \"inner\")\n",
    "\n",
    "rec_4291095_check.shape[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Filename', 'UnitID', 'View'], dtype='object')"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_2813153.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "523"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_2813153_check = pd.merge(master_checksums.loc[master_checksums[\"record_number\"] == 2813153],\n",
    "                             df_2813153,\n",
    "                             left_on = \"Image_name\",\n",
    "                             right_on = \"Filename\",\n",
    "                             how = \"inner\")\n",
    "\n",
    "rec_2813153_check.shape[0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These do both seem to align properly, are the `UnitID`/`unit.id` overlapping for 415 images?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "415\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "X_x               415\n",
       "Image_name_x      415\n",
       "CAMID             104\n",
       "unit.id           104\n",
       "md5               415\n",
       "Taxonomic_Name      1\n",
       "X_y               415\n",
       "Image_name_y      415\n",
       "UnitID            104\n",
       "dtype: int64"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_match = pd.merge(rec_4291095_check[[\"X\", \"Image_name\", \"CAMID\", \"unit.id\", \"md5\", \"Taxonomic_Name\"]],\n",
    "                    rec_2813153_check[[\"X\", \"Image_name\", \"CAMID\", \"UnitID\", \"md5\", \"Taxonomic_Name\"]],\n",
    "                    left_on = [\"CAMID\", \"unit.id\", \"Taxonomic_Name\", \"md5\"],\n",
    "                    right_on = [\"CAMID\", \"UnitID\", \"Taxonomic_Name\", \"md5\"],\n",
    "                    how = \"inner\")\n",
    "\n",
    "print(rec_match.shape[0])\n",
    "rec_match.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X_x</th>\n",
       "      <th>Image_name_x</th>\n",
       "      <th>CAMID</th>\n",
       "      <th>unit.id</th>\n",
       "      <th>md5</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>X_y</th>\n",
       "      <th>Image_name_y</th>\n",
       "      <th>UnitID</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>40194</td>\n",
       "      <td>CAM041807_d.CR2</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>1ef3dbe7b286a34882d21ef39424f18a</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>14461</td>\n",
       "      <td>CAM041807_d.CR2</td>\n",
       "      <td>CAM041807</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>40197</td>\n",
       "      <td>CAM041807_v.JPG</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>844f9b09adda5d919694a8c1a38ca991</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>14464</td>\n",
       "      <td>CAM041807_v.JPG</td>\n",
       "      <td>CAM041807</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>40195</td>\n",
       "      <td>CAM041807_d.JPG</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>1e77684537bc187b8e82b0f9f4342275</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>14462</td>\n",
       "      <td>CAM041807_d.JPG</td>\n",
       "      <td>CAM041807</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>40196</td>\n",
       "      <td>CAM041807_v.CR2</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>CAM041807</td>\n",
       "      <td>b1daeb529e16952906c986d193bcc32d</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>14463</td>\n",
       "      <td>CAM041807_v.CR2</td>\n",
       "      <td>CAM041807</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>40198</td>\n",
       "      <td>CAM041808_d.CR2</td>\n",
       "      <td>CAM041808</td>\n",
       "      <td>CAM041808</td>\n",
       "      <td>e1b16f08005517abfda5ef098b11b8b1</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>14465</td>\n",
       "      <td>CAM041808_d.CR2</td>\n",
       "      <td>CAM041808</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     X_x     Image_name_x      CAMID    unit.id  \\\n",
       "0  40194  CAM041807_d.CR2  CAM041807  CAM041807   \n",
       "1  40197  CAM041807_v.JPG  CAM041807  CAM041807   \n",
       "2  40195  CAM041807_d.JPG  CAM041807  CAM041807   \n",
       "3  40196  CAM041807_v.CR2  CAM041807  CAM041807   \n",
       "4  40198  CAM041808_d.CR2  CAM041808  CAM041808   \n",
       "\n",
       "                                md5                   Taxonomic_Name    X_y  \\\n",
       "0  1ef3dbe7b286a34882d21ef39424f18a  Heliconius erato ssp. lativitta  14461   \n",
       "1  844f9b09adda5d919694a8c1a38ca991  Heliconius erato ssp. lativitta  14464   \n",
       "2  1e77684537bc187b8e82b0f9f4342275  Heliconius erato ssp. lativitta  14462   \n",
       "3  b1daeb529e16952906c986d193bcc32d  Heliconius erato ssp. lativitta  14463   \n",
       "4  e1b16f08005517abfda5ef098b11b8b1  Heliconius erato ssp. lativitta  14465   \n",
       "\n",
       "      Image_name_y     UnitID  \n",
       "0  CAM041807_d.CR2  CAM041807  \n",
       "1  CAM041807_v.JPG  CAM041807  \n",
       "2  CAM041807_d.JPG  CAM041807  \n",
       "3  CAM041807_v.CR2  CAM041807  \n",
       "4  CAM041808_d.CR2  CAM041808  "
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_match.head()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The big question in removing duplicate records is just if all the metadata assoicated to the image remains the same. This would be all metadata other than `record_number`, `file_url`, `X`, `zenodo_link`, `zenodo_name` (CSV source), `Dataset` (Zenodo record name), `Image_name`, and possibly some other columns we don't usually work with."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['CAMID',\n",
       " 'View',\n",
       " 'Sequence',\n",
       " 'Taxonomic_Name',\n",
       " 'Locality',\n",
       " 'Other_ID',\n",
       " 'Store',\n",
       " 'Brood',\n",
       " 'Sex',\n",
       " 'Unit_Type',\n",
       " 'file_type',\n",
       " 'species',\n",
       " 'subspecies',\n",
       " 'genus',\n",
       " 'hybrid_stat',\n",
       " 'md5']"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "diff_cols = [\"record_number\", \"file_url\", \"X\", \"zenodo_link\", \"zenodo_name\", \"filename\", \"filepath\", \"Image_name\", \"Dataset\"]\n",
    "\n",
    "merge_cols = [col for col in list(no_patch_duplicates.columns)[:-1] if (no_patch_duplicates.loc[no_patch_duplicates[col].notna()].shape[0] > 0) and (col not in diff_cols)]\n",
    "merge_cols"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Start with these two larger overlaps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(415, 32)"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_2813153 = no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"] == 2813153]\n",
    "rec_2813153.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "311"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "merge_check = pd.merge(rec_4291095,\n",
    "                       rec_2813153,\n",
    "                       on = merge_cols,\n",
    "                       how = \"inner\")\n",
    "\n",
    "merge_check.shape[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['CAMID',\n",
       " 'X',\n",
       " 'Image_name',\n",
       " 'View',\n",
       " 'zenodo_name',\n",
       " 'zenodo_link',\n",
       " 'Sequence',\n",
       " 'Taxonomic_Name',\n",
       " 'Locality',\n",
       " 'Other_ID',\n",
       " 'Dataset',\n",
       " 'Store',\n",
       " 'Brood',\n",
       " 'Sex',\n",
       " 'Unit_Type',\n",
       " 'file_type',\n",
       " 'record_number',\n",
       " 'species',\n",
       " 'subspecies',\n",
       " 'genus',\n",
       " 'file_url',\n",
       " 'hybrid_stat',\n",
       " 'filename',\n",
       " 'filepath',\n",
       " 'md5']"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "overlap_non_null_cols = [col for col in list(no_patch_duplicates.columns)[:-1] if (no_patch_duplicates.loc[no_patch_duplicates[col].notna()].shape[0] > 0)]\n",
    "overlap_non_null_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CAMID 415\n",
      "X 0\n",
      "Image_name 415\n",
      "View 311\n",
      "zenodo_name 0\n",
      "zenodo_link 0\n",
      "Sequence 415\n",
      "Taxonomic_Name 415\n",
      "Locality 415\n",
      "Other_ID 415\n",
      "Dataset 415\n",
      "Store 415\n",
      "Brood 415\n",
      "Sex 415\n",
      "Unit_Type 415\n",
      "file_type 415\n",
      "record_number 0\n",
      "species 415\n",
      "subspecies 415\n",
      "genus 415\n",
      "file_url 0\n",
      "hybrid_stat 415\n",
      "filename 0\n",
      "filepath 0\n",
      "md5 415\n"
     ]
    }
   ],
   "source": [
    "for col in overlap_non_null_cols:\n",
    "    merge_on = [\"md5\", col]\n",
    "    temp = pd.merge(rec_2813153,\n",
    "                    rec_4291095,\n",
    "                    on = merge_on,\n",
    "                    how = \"inner\")\n",
    "    print(col, temp.shape[0])\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Expected columns fail, but also `View` seems to be an issue, so let's look at where the view disagrees. Note that the `Image_name` seems to match for all of them, this could be an option for checking proper views."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(415, 9)"
      ]
     },
     "execution_count": 130,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view_check_cols = [\"X\", \"Image_name\", \"CAMID\", \"md5\", \"Taxonomic_Name\", \"View\", \"file_type\"]\n",
    "view_check = pd.merge(rec_2813153[view_check_cols],\n",
    "                      rec_4291095[view_check_cols],\n",
    "                      on = [\"Image_name\", \"CAMID\", \"md5\", \"Taxonomic_Name\", \"file_type\"],\n",
    "                      suffixes = (\"_28\", \"_42\"),\n",
    "                      how = \"inner\")\n",
    "\n",
    "view_check.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "mismatched_view\n",
       "False    311\n",
       "True     104\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view_check[\"mismatched_view\"] = view_check[\"View_28\"] != view_check[\"View_42\"]\n",
    "view_check[\"mismatched_view\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X_28</th>\n",
       "      <th>Image_name</th>\n",
       "      <th>CAMID</th>\n",
       "      <th>md5</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>View_28</th>\n",
       "      <th>file_type</th>\n",
       "      <th>X_42</th>\n",
       "      <th>View_42</th>\n",
       "      <th>mismatched_view</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>14599</td>\n",
       "      <td>CAM041841_v.CR2</td>\n",
       "      <td>CAM041841</td>\n",
       "      <td>005a48b915e7c5a750648e5f37ea5fd8</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40332</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>14579</td>\n",
       "      <td>CAM041836_v.CR2</td>\n",
       "      <td>CAM041836</td>\n",
       "      <td>6c816d18dc8c903fbdbfb93f4c04c3b0</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40312</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>14611</td>\n",
       "      <td>CAM041844_v.CR2</td>\n",
       "      <td>CAM041844</td>\n",
       "      <td>59e2410288a9636c691086cc3720c761</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40344</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>14519</td>\n",
       "      <td>CAM041821_v.CR2</td>\n",
       "      <td>CAM041821</td>\n",
       "      <td>57163f6da6697359d233a6e712373b7d</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40252</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>281</th>\n",
       "      <td>14743</td>\n",
       "      <td>CAM041878_v.CR2</td>\n",
       "      <td>CAM041878</td>\n",
       "      <td>171701048825a19051127dc253e39e50</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40477</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>14547</td>\n",
       "      <td>CAM041828_v.CR2</td>\n",
       "      <td>CAM041828</td>\n",
       "      <td>c6de0b670edbe46881497bf60b1f9853</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40280</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194</th>\n",
       "      <td>14655</td>\n",
       "      <td>CAM041856_v.CR2</td>\n",
       "      <td>CAM041856</td>\n",
       "      <td>6f5face02339ba69483f6dbf6c0aa601</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40389</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>14479</td>\n",
       "      <td>CAM041811_v.CR2</td>\n",
       "      <td>CAM041811</td>\n",
       "      <td>9cb25be5951488b9e37342586cb678f6</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40212</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>290</th>\n",
       "      <td>14751</td>\n",
       "      <td>CAM041880_v.CR2</td>\n",
       "      <td>CAM041880</td>\n",
       "      <td>b27fa3842baba1f3bb1679419dd009e7</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40485</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>310</th>\n",
       "      <td>14771</td>\n",
       "      <td>CAM041885_v.CR2</td>\n",
       "      <td>CAM041885</td>\n",
       "      <td>d7105469b2c4b24fb288e7e3b9b1241d</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>raw</td>\n",
       "      <td>40505</td>\n",
       "      <td>ventral</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      X_28       Image_name      CAMID                               md5  \\\n",
       "136  14599  CAM041841_v.CR2  CAM041841  005a48b915e7c5a750648e5f37ea5fd8   \n",
       "118  14579  CAM041836_v.CR2  CAM041836  6c816d18dc8c903fbdbfb93f4c04c3b0   \n",
       "148  14611  CAM041844_v.CR2  CAM041844  59e2410288a9636c691086cc3720c761   \n",
       "56   14519  CAM041821_v.CR2  CAM041821  57163f6da6697359d233a6e712373b7d   \n",
       "281  14743  CAM041878_v.CR2  CAM041878  171701048825a19051127dc253e39e50   \n",
       "86   14547  CAM041828_v.CR2  CAM041828  c6de0b670edbe46881497bf60b1f9853   \n",
       "194  14655  CAM041856_v.CR2  CAM041856  6f5face02339ba69483f6dbf6c0aa601   \n",
       "18   14479  CAM041811_v.CR2  CAM041811  9cb25be5951488b9e37342586cb678f6   \n",
       "290  14751  CAM041880_v.CR2  CAM041880  b27fa3842baba1f3bb1679419dd009e7   \n",
       "310  14771  CAM041885_v.CR2  CAM041885  d7105469b2c4b24fb288e7e3b9b1241d   \n",
       "\n",
       "                      Taxonomic_Name View_28 file_type   X_42  View_42  \\\n",
       "136  Heliconius erato ssp. lativitta  dorsal       raw  40332  ventral   \n",
       "118  Heliconius erato ssp. lativitta  dorsal       raw  40312  ventral   \n",
       "148  Heliconius erato ssp. lativitta  dorsal       raw  40344  ventral   \n",
       "56   Heliconius erato ssp. lativitta  dorsal       raw  40252  ventral   \n",
       "281  Heliconius erato ssp. lativitta  dorsal       raw  40477  ventral   \n",
       "86   Heliconius erato ssp. lativitta  dorsal       raw  40280  ventral   \n",
       "194  Heliconius erato ssp. lativitta  dorsal       raw  40389  ventral   \n",
       "18   Heliconius erato ssp. lativitta  dorsal       raw  40212  ventral   \n",
       "290  Heliconius erato ssp. lativitta  dorsal       raw  40485  ventral   \n",
       "310  Heliconius erato ssp. lativitta  dorsal       raw  40505  ventral   \n",
       "\n",
       "     mismatched_view  \n",
       "136             True  \n",
       "118             True  \n",
       "148             True  \n",
       "56              True  \n",
       "281             True  \n",
       "86              True  \n",
       "194             True  \n",
       "18              True  \n",
       "290             True  \n",
       "310             True  "
      ]
     },
     "execution_count": 132,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view_check.loc[view_check[\"mismatched_view\"]].sample(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "file_type\n",
       "raw    104\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 133,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "view_check.loc[view_check[\"mismatched_view\"], \"file_type\"].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Ahh only the raw photos have the mismatch. Were they the only ones mislabeled or were their associated JPGs mislabeled?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X_28</th>\n",
       "      <th>Image_name</th>\n",
       "      <th>CAMID</th>\n",
       "      <th>md5</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>View_28</th>\n",
       "      <th>file_type</th>\n",
       "      <th>X_42</th>\n",
       "      <th>View_42</th>\n",
       "      <th>mismatched_view</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>276</th>\n",
       "      <td>14738</td>\n",
       "      <td>CAM041877_d.JPG</td>\n",
       "      <td>CAM041877</td>\n",
       "      <td>7cba96d6031a6c4b8ccdb9971a5f9728</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40472</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>14582</td>\n",
       "      <td>CAM041837_d.JPG</td>\n",
       "      <td>CAM041837</td>\n",
       "      <td>a7cc8d0b392b2088e122b736e8a09650</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40315</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>346</th>\n",
       "      <td>14810</td>\n",
       "      <td>CAM041895_d.JPG</td>\n",
       "      <td>CAM041895</td>\n",
       "      <td>60d3c82b6c57c08e3c71b73982aa1f09</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40544</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>278</th>\n",
       "      <td>14740</td>\n",
       "      <td>CAM041877_v.JPG</td>\n",
       "      <td>CAM041877</td>\n",
       "      <td>46eaec54590b045ab352728a4b12441a</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>ventral</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40474</td>\n",
       "      <td>ventral</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>180</th>\n",
       "      <td>14644</td>\n",
       "      <td>CAM041852_v.JPG</td>\n",
       "      <td>CAM041852</td>\n",
       "      <td>40b5d568cf0ab0590756181307dbf3df</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>ventral</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40377</td>\n",
       "      <td>ventral</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>176</th>\n",
       "      <td>14638</td>\n",
       "      <td>CAM041851_d.JPG</td>\n",
       "      <td>CAM041851</td>\n",
       "      <td>6e0ef053a5208fb33fe612777e85fe90</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40371</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>14564</td>\n",
       "      <td>CAM041832_v.JPG</td>\n",
       "      <td>CAM041832</td>\n",
       "      <td>a0f4b27b90a322c36c26d8375f303adb</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>ventral</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40297</td>\n",
       "      <td>ventral</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>14534</td>\n",
       "      <td>CAM041825_d.JPG</td>\n",
       "      <td>CAM041825</td>\n",
       "      <td>795185b9e27ff897d94278a11eec5c99</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40267</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>186</th>\n",
       "      <td>14646</td>\n",
       "      <td>CAM041853_d.JPG</td>\n",
       "      <td>CAM041853</td>\n",
       "      <td>9f3ad95d8ff999ac4b8bb76cad171aaf</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40379</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>283</th>\n",
       "      <td>14742</td>\n",
       "      <td>CAM041878_d.JPG</td>\n",
       "      <td>CAM041878</td>\n",
       "      <td>c0d154ebbf7552bcdbcb233556a5f286</td>\n",
       "      <td>Heliconius erato ssp. lativitta</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>jpg</td>\n",
       "      <td>40476</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      X_28       Image_name      CAMID                               md5  \\\n",
       "276  14738  CAM041877_d.JPG  CAM041877  7cba96d6031a6c4b8ccdb9971a5f9728   \n",
       "121  14582  CAM041837_d.JPG  CAM041837  a7cc8d0b392b2088e122b736e8a09650   \n",
       "346  14810  CAM041895_d.JPG  CAM041895  60d3c82b6c57c08e3c71b73982aa1f09   \n",
       "278  14740  CAM041877_v.JPG  CAM041877  46eaec54590b045ab352728a4b12441a   \n",
       "180  14644  CAM041852_v.JPG  CAM041852  40b5d568cf0ab0590756181307dbf3df   \n",
       "176  14638  CAM041851_d.JPG  CAM041851  6e0ef053a5208fb33fe612777e85fe90   \n",
       "103  14564  CAM041832_v.JPG  CAM041832  a0f4b27b90a322c36c26d8375f303adb   \n",
       "74   14534  CAM041825_d.JPG  CAM041825  795185b9e27ff897d94278a11eec5c99   \n",
       "186  14646  CAM041853_d.JPG  CAM041853  9f3ad95d8ff999ac4b8bb76cad171aaf   \n",
       "283  14742  CAM041878_d.JPG  CAM041878  c0d154ebbf7552bcdbcb233556a5f286   \n",
       "\n",
       "                      Taxonomic_Name  View_28 file_type   X_42  View_42  \\\n",
       "276  Heliconius erato ssp. lativitta   dorsal       jpg  40472   dorsal   \n",
       "121  Heliconius erato ssp. lativitta   dorsal       jpg  40315   dorsal   \n",
       "346  Heliconius erato ssp. lativitta   dorsal       jpg  40544   dorsal   \n",
       "278  Heliconius erato ssp. lativitta  ventral       jpg  40474  ventral   \n",
       "180  Heliconius erato ssp. lativitta  ventral       jpg  40377  ventral   \n",
       "176  Heliconius erato ssp. lativitta   dorsal       jpg  40371   dorsal   \n",
       "103  Heliconius erato ssp. lativitta  ventral       jpg  40297  ventral   \n",
       "74   Heliconius erato ssp. lativitta   dorsal       jpg  40267   dorsal   \n",
       "186  Heliconius erato ssp. lativitta   dorsal       jpg  40379   dorsal   \n",
       "283  Heliconius erato ssp. lativitta   dorsal       jpg  40476   dorsal   \n",
       "\n",
       "     mismatched_view  \n",
       "276            False  \n",
       "121            False  \n",
       "346            False  \n",
       "278            False  \n",
       "180            False  \n",
       "176            False  \n",
       "103            False  \n",
       "74             False  \n",
       "186            False  \n",
       "283            False  "
      ]
     },
     "execution_count": 134,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mismatched_view_cams = list(view_check.loc[view_check[\"mismatched_view\"], \"CAMID\"].unique())\n",
    "view_check.loc[(view_check[\"CAMID\"].isin(mismatched_view_cams)) & (view_check[\"file_type\"] == \"jpg\")].sample(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "OK, it _seems_ that it was just the raw photos that were mislabeled. We'll keep those updates."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From this sample, it looks like record 42 fixed some mislabels from record 28. Should probably check if record 3477891 fixed mislabeling from the earlier records that it duplicated."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Check Record 3477891 Duplicates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID          2704\n",
       "Image_name     5497\n",
       "X             10998\n",
       "filename      10998\n",
       "md5            5497\n",
       "file_url       5497\n",
       "dtype: int64"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "md5s_3477891 = list(master_checksums.loc[master_checksums[\"record_number\"] == 3477891, \"md5\"].unique())\n",
    "patch_dupes = master_checksums.loc[master_checksums[\"md5\"].isin(md5s_3477891)]\n",
    "patch_dupes[id_cols].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [],
   "source": [
    "patch_df = patch_dupes.loc[patch_dupes[\"record_number\"] == 3477891]\n",
    "patch_matches = patch_dupes.loc[patch_dupes[\"record_number\"] != 3477891]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CAMID 5501\n",
      "X 0\n",
      "Image_name 5501\n",
      "View 5495\n",
      "zenodo_name 0\n",
      "zenodo_link 0\n",
      "Sequence 5501\n",
      "Taxonomic_Name 5501\n",
      "Locality 5501\n",
      "Sample_accession 5501\n",
      "Other_ID 5501\n",
      "Date 5501\n",
      "Dataset 5501\n",
      "Store 5501\n",
      "Brood 5501\n",
      "Sex 5501\n",
      "Unit_Type 5501\n",
      "file_type 5501\n",
      "record_number 0\n",
      "species 5501\n",
      "subspecies 5501\n",
      "genus 5501\n",
      "file_url 5501\n",
      "hybrid_stat 5501\n",
      "filename 0\n",
      "filepath 0\n",
      "md5 5501\n"
     ]
    }
   ],
   "source": [
    "patch_non_null_cols = [col for col in list(patch_dupes.columns)[:-1] if (patch_dupes.loc[patch_dupes[col].notna()].shape[0] > 0)]\n",
    "for col in patch_non_null_cols:\n",
    "    merge_on = [\"md5\", col]\n",
    "    temp = pd.merge(patch_df,\n",
    "                    patch_matches,\n",
    "                    on = merge_on,\n",
    "                    how = \"inner\")\n",
    "    print(col, temp.shape[0])\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We again have the only inconsistency in the `View` column, where they do not align exactly (though it's only 6 differences)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5501, 8)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "mismatched_view\n",
       "False    5495\n",
       "True        6\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "patch_view_check = pd.merge(patch_matches[view_check_cols],\n",
    "                      patch_df[view_check_cols],\n",
    "                      on = [\"Image_name\", \"CAMID\", \"md5\", \"Taxonomic_Name\"],\n",
    "                      suffixes = (\"_old\", \"_patch\"),\n",
    "                      how = \"inner\")\n",
    "\n",
    "print(patch_view_check.shape)\n",
    "\n",
    "patch_view_check[\"mismatched_view\"] = patch_view_check[\"View_old\"] != patch_view_check[\"View_patch\"]\n",
    "patch_view_check[\"mismatched_view\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X_old</th>\n",
       "      <th>Image_name</th>\n",
       "      <th>CAMID</th>\n",
       "      <th>md5</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>View_old</th>\n",
       "      <th>X_patch</th>\n",
       "      <th>View_patch</th>\n",
       "      <th>mismatched_view</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1689</th>\n",
       "      <td>26075</td>\n",
       "      <td>DSC_0697.jpg</td>\n",
       "      <td>CAM008523</td>\n",
       "      <td>764c722faeefa48aed09aef1956738a8</td>\n",
       "      <td>Heliconius timareta ssp. timareta</td>\n",
       "      <td>ventral</td>\n",
       "      <td>49955</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1871</th>\n",
       "      <td>26059</td>\n",
       "      <td>8624-UND.jpg</td>\n",
       "      <td>CAM008624</td>\n",
       "      <td>4a3b6c97a131436f3e5f95b0ef7695d2</td>\n",
       "      <td>Heliconius timareta ssp. thelxinoe</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44341</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1880</th>\n",
       "      <td>26061</td>\n",
       "      <td>8628-UND.jpg</td>\n",
       "      <td>CAM008628</td>\n",
       "      <td>97fdfb3de2e4a34f1c243056348962c5</td>\n",
       "      <td>Heliconius timareta ssp. thelxinoe</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44342</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1886</th>\n",
       "      <td>26063</td>\n",
       "      <td>8631-UND.jpg</td>\n",
       "      <td>CAM008631</td>\n",
       "      <td>e1c82f4e814c7a6c56ebc34b0f502298</td>\n",
       "      <td>Heliconius timareta ssp. thelxinoe</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44343</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2516</th>\n",
       "      <td>26066</td>\n",
       "      <td>9117_H_m_ecuadorensis_V.JPG.jpg</td>\n",
       "      <td>CAM009117</td>\n",
       "      <td>66a8b638d961955d3cd168c3168667ed</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44375</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2531</th>\n",
       "      <td>26068</td>\n",
       "      <td>9121_H_m_ecuadorensis_V.JPG.jpg</td>\n",
       "      <td>CAM009121</td>\n",
       "      <td>a14ff471e6be6c26bc2c0d8409a7a1e0</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44379</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      X_old                       Image_name      CAMID  \\\n",
       "1689  26075                     DSC_0697.jpg  CAM008523   \n",
       "1871  26059                     8624-UND.jpg  CAM008624   \n",
       "1880  26061                     8628-UND.jpg  CAM008628   \n",
       "1886  26063                     8631-UND.jpg  CAM008631   \n",
       "2516  26066  9117_H_m_ecuadorensis_V.JPG.jpg  CAM009117   \n",
       "2531  26068  9121_H_m_ecuadorensis_V.JPG.jpg  CAM009121   \n",
       "\n",
       "                                   md5  \\\n",
       "1689  764c722faeefa48aed09aef1956738a8   \n",
       "1871  4a3b6c97a131436f3e5f95b0ef7695d2   \n",
       "1880  97fdfb3de2e4a34f1c243056348962c5   \n",
       "1886  e1c82f4e814c7a6c56ebc34b0f502298   \n",
       "2516  66a8b638d961955d3cd168c3168667ed   \n",
       "2531  a14ff471e6be6c26bc2c0d8409a7a1e0   \n",
       "\n",
       "                              Taxonomic_Name View_old  X_patch View_patch  \\\n",
       "1689       Heliconius timareta ssp. timareta  ventral    49955     dorsal   \n",
       "1871      Heliconius timareta ssp. thelxinoe  ventral    44341     dorsal   \n",
       "1880      Heliconius timareta ssp. thelxinoe  ventral    44342     dorsal   \n",
       "1886      Heliconius timareta ssp. thelxinoe  ventral    44343     dorsal   \n",
       "2516  Heliconius melpomene ssp. ecuadorensis  ventral    44375     dorsal   \n",
       "2531  Heliconius melpomene ssp. ecuadorensis  ventral    44379     dorsal   \n",
       "\n",
       "      mismatched_view  \n",
       "1689             True  \n",
       "1871             True  \n",
       "1880             True  \n",
       "1886             True  \n",
       "2516             True  \n",
       "2531             True  "
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "patch_view_check.loc[patch_view_check[\"mismatched_view\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X_old</th>\n",
       "      <th>Image_name</th>\n",
       "      <th>CAMID</th>\n",
       "      <th>md5</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>View_old</th>\n",
       "      <th>X_patch</th>\n",
       "      <th>View_patch</th>\n",
       "      <th>mismatched_view</th>\n",
       "      <th>md5_dupe</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2516</th>\n",
       "      <td>26066</td>\n",
       "      <td>9117_H_m_ecuadorensis_V.JPG.jpg</td>\n",
       "      <td>CAM009117</td>\n",
       "      <td>66a8b638d961955d3cd168c3168667ed</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44375</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2517</th>\n",
       "      <td>26066</td>\n",
       "      <td>9117_H_m_ecuadorensis_V.JPG.jpg</td>\n",
       "      <td>CAM009117</td>\n",
       "      <td>66a8b638d961955d3cd168c3168667ed</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44374</td>\n",
       "      <td>ventral</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2519</th>\n",
       "      <td>26065</td>\n",
       "      <td>9117_H_m_ecuadorensis_D.JPG.jpg</td>\n",
       "      <td>CAM009117</td>\n",
       "      <td>d10fcc5232e4c994d32e8181cb6e71e1</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>44372</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2520</th>\n",
       "      <td>26065</td>\n",
       "      <td>9117_H_m_ecuadorensis_D.JPG.jpg</td>\n",
       "      <td>CAM009117</td>\n",
       "      <td>d10fcc5232e4c994d32e8181cb6e71e1</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>44373</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2529</th>\n",
       "      <td>26067</td>\n",
       "      <td>9121_H_m_ecuadorensis_D.JPG.jpg</td>\n",
       "      <td>CAM009121</td>\n",
       "      <td>d53b79f77d12e7da1eb2ddf17418de9c</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>44376</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2530</th>\n",
       "      <td>26067</td>\n",
       "      <td>9121_H_m_ecuadorensis_D.JPG.jpg</td>\n",
       "      <td>CAM009121</td>\n",
       "      <td>d53b79f77d12e7da1eb2ddf17418de9c</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>44377</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2531</th>\n",
       "      <td>26068</td>\n",
       "      <td>9121_H_m_ecuadorensis_V.JPG.jpg</td>\n",
       "      <td>CAM009121</td>\n",
       "      <td>a14ff471e6be6c26bc2c0d8409a7a1e0</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44379</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2532</th>\n",
       "      <td>26068</td>\n",
       "      <td>9121_H_m_ecuadorensis_V.JPG.jpg</td>\n",
       "      <td>CAM009121</td>\n",
       "      <td>a14ff471e6be6c26bc2c0d8409a7a1e0</td>\n",
       "      <td>Heliconius melpomene ssp. ecuadorensis</td>\n",
       "      <td>ventral</td>\n",
       "      <td>44378</td>\n",
       "      <td>ventral</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      X_old                       Image_name      CAMID  \\\n",
       "2516  26066  9117_H_m_ecuadorensis_V.JPG.jpg  CAM009117   \n",
       "2517  26066  9117_H_m_ecuadorensis_V.JPG.jpg  CAM009117   \n",
       "2519  26065  9117_H_m_ecuadorensis_D.JPG.jpg  CAM009117   \n",
       "2520  26065  9117_H_m_ecuadorensis_D.JPG.jpg  CAM009117   \n",
       "2529  26067  9121_H_m_ecuadorensis_D.JPG.jpg  CAM009121   \n",
       "2530  26067  9121_H_m_ecuadorensis_D.JPG.jpg  CAM009121   \n",
       "2531  26068  9121_H_m_ecuadorensis_V.JPG.jpg  CAM009121   \n",
       "2532  26068  9121_H_m_ecuadorensis_V.JPG.jpg  CAM009121   \n",
       "\n",
       "                                   md5  \\\n",
       "2516  66a8b638d961955d3cd168c3168667ed   \n",
       "2517  66a8b638d961955d3cd168c3168667ed   \n",
       "2519  d10fcc5232e4c994d32e8181cb6e71e1   \n",
       "2520  d10fcc5232e4c994d32e8181cb6e71e1   \n",
       "2529  d53b79f77d12e7da1eb2ddf17418de9c   \n",
       "2530  d53b79f77d12e7da1eb2ddf17418de9c   \n",
       "2531  a14ff471e6be6c26bc2c0d8409a7a1e0   \n",
       "2532  a14ff471e6be6c26bc2c0d8409a7a1e0   \n",
       "\n",
       "                              Taxonomic_Name View_old  X_patch View_patch  \\\n",
       "2516  Heliconius melpomene ssp. ecuadorensis  ventral    44375     dorsal   \n",
       "2517  Heliconius melpomene ssp. ecuadorensis  ventral    44374    ventral   \n",
       "2519  Heliconius melpomene ssp. ecuadorensis   dorsal    44372     dorsal   \n",
       "2520  Heliconius melpomene ssp. ecuadorensis   dorsal    44373     dorsal   \n",
       "2529  Heliconius melpomene ssp. ecuadorensis   dorsal    44376     dorsal   \n",
       "2530  Heliconius melpomene ssp. ecuadorensis   dorsal    44377     dorsal   \n",
       "2531  Heliconius melpomene ssp. ecuadorensis  ventral    44379     dorsal   \n",
       "2532  Heliconius melpomene ssp. ecuadorensis  ventral    44378    ventral   \n",
       "\n",
       "      mismatched_view  md5_dupe  \n",
       "2516             True      True  \n",
       "2517            False      True  \n",
       "2519            False      True  \n",
       "2520            False      True  \n",
       "2529            False      True  \n",
       "2530            False      True  \n",
       "2531             True      True  \n",
       "2532            False      True  "
      ]
     },
     "execution_count": 128,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "patch_view_check[\"md5_dupe\"] = patch_view_check.duplicated(\"md5\", keep = False)\n",
    "patch_view_check.loc[patch_view_check[\"md5_dupe\"]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Manual check and confirmation with Christopher suggests that the additions (and duplications) were mislabled, so we will be proceeding without the patch."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Check the final Non-patch duplicates\n",
    "Those not in records `4291095, 2813153`:\n",
    "```\n",
    "5526257     20\n",
    "2553977      8\n",
    "2552371      2\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 135,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "small_overlap = no_patch_duplicates.loc[~no_patch_duplicates[\"record_number\"].isin([4291095, 2813153])]\n",
    "small_overlap.md5.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CAMID</th>\n",
       "      <th>X</th>\n",
       "      <th>Image_name</th>\n",
       "      <th>View</th>\n",
       "      <th>zenodo_name</th>\n",
       "      <th>zenodo_link</th>\n",
       "      <th>Sequence</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>Locality</th>\n",
       "      <th>Sample_accession</th>\n",
       "      <th>...</th>\n",
       "      <th>record_number</th>\n",
       "      <th>species</th>\n",
       "      <th>subspecies</th>\n",
       "      <th>genus</th>\n",
       "      <th>file_url</th>\n",
       "      <th>hybrid_stat</th>\n",
       "      <th>filename</th>\n",
       "      <th>filepath</th>\n",
       "      <th>md5</th>\n",
       "      <th>duplicate_md5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>11978</th>\n",
       "      <td>CAM010354</td>\n",
       "      <td>23471</td>\n",
       "      <td>10354d.jpg</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
       "      <td>https://zenodo.org/record/2552371</td>\n",
       "      <td>10,354</td>\n",
       "      <td>Heliconius sp.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2552371</td>\n",
       "      <td>Heliconius sp.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2552371/files/10354d...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>23471_10354d.jpg</td>\n",
       "      <td>images/Heliconius sp./23471_10354d.jpg</td>\n",
       "      <td>84d4ac6527458786cdb33166cd80e0a8</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12010</th>\n",
       "      <td>CAM010362</td>\n",
       "      <td>23484</td>\n",
       "      <td>10362v.jpg</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
       "      <td>https://zenodo.org/record/2552371</td>\n",
       "      <td>10,362</td>\n",
       "      <td>Heliconius sp.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2552371</td>\n",
       "      <td>Heliconius sp.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2552371/files/10362v...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>23484_10362v.jpg</td>\n",
       "      <td>images/Heliconius sp./23484_10362v.jpg</td>\n",
       "      <td>84d4ac6527458786cdb33166cd80e0a8</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40112</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26102</td>\n",
       "      <td>CAM050036_S1_9_FW_IMG_8547_wb_2.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,036</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26102_CAM050036_S1_9_FW_IMG_8547_wb_2.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26102_CAM0500...</td>\n",
       "      <td>34adbd5596f977834fb2c6876d2f4493</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40113</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26105</td>\n",
       "      <td>CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,036</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26105_CAM0500...</td>\n",
       "      <td>6d63d659fbc02369010938bbc229ad4d</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40116</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26115</td>\n",
       "      <td>CAM050036_S1_9_FW_IMG_8547_cut_2.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,036</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26115_CAM050036_S1_9_FW_IMG_8547_cut_2.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26115_CAM0500...</td>\n",
       "      <td>34adbd5596f977834fb2c6876d2f4493</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40120</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26116</td>\n",
       "      <td>CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,036</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26116_CAM0500...</td>\n",
       "      <td>6d63d659fbc02369010938bbc229ad4d</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40138</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26112</td>\n",
       "      <td>CAM050147_DS1_IMG_8513_4.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,147</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26112_CAM050147_DS1_IMG_8513_4.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26112_CAM0501...</td>\n",
       "      <td>464801449aa127933d9619cb4e6f0a01</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40141</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26197</td>\n",
       "      <td>CAM050147_DS1_HW_IMG_8537_cut_3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,147</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26197_CAM050147_DS1_HW_IMG_8537_cut_3.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26197_CAM0501...</td>\n",
       "      <td>21e726df7076f5c13fe1441126bac4d5</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40144</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26196</td>\n",
       "      <td>CAM050147_DS1_HW_IMG_8537_cut_3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,147</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26196_CAM050147_DS1_HW_IMG_8537_cut_3.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26196_CAM0501...</td>\n",
       "      <td>21e726df7076f5c13fe1441126bac4d5</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40145</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26117</td>\n",
       "      <td>CAM050147_DS1_FW_IMG_8513_cut_4.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "      <td>50,147</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>2553977</td>\n",
       "      <td>Heliconius sara</td>\n",
       "      <td>sara</td>\n",
       "      <td>Heliconius</td>\n",
       "      <td>https://zenodo.org/record/2553977/files/CAM050...</td>\n",
       "      <td>non-hybrid</td>\n",
       "      <td>26117_CAM050147_DS1_FW_IMG_8513_cut_4.tif</td>\n",
       "      <td>images/Heliconius sara ssp. sara/26117_CAM0501...</td>\n",
       "      <td>464801449aa127933d9619cb4e6f0a01</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 32 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID      X                               Image_name     View  \\\n",
       "11978  CAM010354  23471                               10354d.jpg   dorsal   \n",
       "12010  CAM010362  23484                               10362v.jpg  ventral   \n",
       "40112  CAM050036  26102      CAM050036_S1_9_FW_IMG_8547_wb_2.tif   dorsal   \n",
       "40113  CAM050036  26105   CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif   dorsal   \n",
       "40116  CAM050036  26115     CAM050036_S1_9_FW_IMG_8547_cut_2.tif   dorsal   \n",
       "40120  CAM050036  26116  CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif   dorsal   \n",
       "40138  CAM050147  26112             CAM050147_DS1_IMG_8513_4.tif   dorsal   \n",
       "40141  CAM050147  26197      CAM050147_DS1_HW_IMG_8537_cut_3.tif   dorsal   \n",
       "40144  CAM050147  26196      CAM050147_DS1_HW_IMG_8537_cut_3.tif   dorsal   \n",
       "40145  CAM050147  26117      CAM050147_DS1_FW_IMG_8513_cut_4.tif   dorsal   \n",
       "\n",
       "                                          zenodo_name  \\\n",
       "11978  Heliconius_wing_old_photos_2001_2019_part1.csv   \n",
       "12010  Heliconius_wing_old_photos_2001_2019_part1.csv   \n",
       "40112  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "40113  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "40116  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "40120  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "40138  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "40141  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "40144  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "40145  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "\n",
       "                             zenodo_link Sequence             Taxonomic_Name  \\\n",
       "11978  https://zenodo.org/record/2552371   10,354             Heliconius sp.   \n",
       "12010  https://zenodo.org/record/2552371   10,362             Heliconius sp.   \n",
       "40112  https://zenodo.org/record/2553977   50,036  Heliconius sara ssp. sara   \n",
       "40113  https://zenodo.org/record/2553977   50,036  Heliconius sara ssp. sara   \n",
       "40116  https://zenodo.org/record/2553977   50,036  Heliconius sara ssp. sara   \n",
       "40120  https://zenodo.org/record/2553977   50,036  Heliconius sara ssp. sara   \n",
       "40138  https://zenodo.org/record/2553977   50,147  Heliconius sara ssp. sara   \n",
       "40141  https://zenodo.org/record/2553977   50,147  Heliconius sara ssp. sara   \n",
       "40144  https://zenodo.org/record/2553977   50,147  Heliconius sara ssp. sara   \n",
       "40145  https://zenodo.org/record/2553977   50,147  Heliconius sara ssp. sara   \n",
       "\n",
       "                 Locality Sample_accession  ... record_number  \\\n",
       "11978                 NaN              NaN  ...       2552371   \n",
       "12010                 NaN              NaN  ...       2552371   \n",
       "40112  Gamboa_insectaries              NaN  ...       2553977   \n",
       "40113  Gamboa_insectaries              NaN  ...       2553977   \n",
       "40116  Gamboa_insectaries              NaN  ...       2553977   \n",
       "40120  Gamboa_insectaries              NaN  ...       2553977   \n",
       "40138           Madingley              NaN  ...       2553977   \n",
       "40141           Madingley              NaN  ...       2553977   \n",
       "40144           Madingley              NaN  ...       2553977   \n",
       "40145           Madingley              NaN  ...       2553977   \n",
       "\n",
       "               species subspecies       genus  \\\n",
       "11978   Heliconius sp.        NaN  Heliconius   \n",
       "12010   Heliconius sp.        NaN  Heliconius   \n",
       "40112  Heliconius sara       sara  Heliconius   \n",
       "40113  Heliconius sara       sara  Heliconius   \n",
       "40116  Heliconius sara       sara  Heliconius   \n",
       "40120  Heliconius sara       sara  Heliconius   \n",
       "40138  Heliconius sara       sara  Heliconius   \n",
       "40141  Heliconius sara       sara  Heliconius   \n",
       "40144  Heliconius sara       sara  Heliconius   \n",
       "40145  Heliconius sara       sara  Heliconius   \n",
       "\n",
       "                                                file_url hybrid_stat  \\\n",
       "11978  https://zenodo.org/record/2552371/files/10354d...         NaN   \n",
       "12010  https://zenodo.org/record/2552371/files/10362v...         NaN   \n",
       "40112  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "40113  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "40116  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "40120  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "40138  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "40141  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "40144  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "40145  https://zenodo.org/record/2553977/files/CAM050...  non-hybrid   \n",
       "\n",
       "                                            filename  \\\n",
       "11978                               23471_10354d.jpg   \n",
       "12010                               23484_10362v.jpg   \n",
       "40112      26102_CAM050036_S1_9_FW_IMG_8547_wb_2.tif   \n",
       "40113   26105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif   \n",
       "40116     26115_CAM050036_S1_9_FW_IMG_8547_cut_2.tif   \n",
       "40120  26116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif   \n",
       "40138             26112_CAM050147_DS1_IMG_8513_4.tif   \n",
       "40141      26197_CAM050147_DS1_HW_IMG_8537_cut_3.tif   \n",
       "40144      26196_CAM050147_DS1_HW_IMG_8537_cut_3.tif   \n",
       "40145      26117_CAM050147_DS1_FW_IMG_8513_cut_4.tif   \n",
       "\n",
       "                                                filepath  \\\n",
       "11978             images/Heliconius sp./23471_10354d.jpg   \n",
       "12010             images/Heliconius sp./23484_10362v.jpg   \n",
       "40112  images/Heliconius sara ssp. sara/26102_CAM0500...   \n",
       "40113  images/Heliconius sara ssp. sara/26105_CAM0500...   \n",
       "40116  images/Heliconius sara ssp. sara/26115_CAM0500...   \n",
       "40120  images/Heliconius sara ssp. sara/26116_CAM0500...   \n",
       "40138  images/Heliconius sara ssp. sara/26112_CAM0501...   \n",
       "40141  images/Heliconius sara ssp. sara/26197_CAM0501...   \n",
       "40144  images/Heliconius sara ssp. sara/26196_CAM0501...   \n",
       "40145  images/Heliconius sara ssp. sara/26117_CAM0501...   \n",
       "\n",
       "                                    md5 duplicate_md5  \n",
       "11978  84d4ac6527458786cdb33166cd80e0a8          True  \n",
       "12010  84d4ac6527458786cdb33166cd80e0a8          True  \n",
       "40112  34adbd5596f977834fb2c6876d2f4493          True  \n",
       "40113  6d63d659fbc02369010938bbc229ad4d          True  \n",
       "40116  34adbd5596f977834fb2c6876d2f4493          True  \n",
       "40120  6d63d659fbc02369010938bbc229ad4d          True  \n",
       "40138  464801449aa127933d9619cb4e6f0a01          True  \n",
       "40141  21e726df7076f5c13fe1441126bac4d5          True  \n",
       "40144  21e726df7076f5c13fe1441126bac4d5          True  \n",
       "40145  464801449aa127933d9619cb4e6f0a01          True  \n",
       "\n",
       "[10 rows x 32 columns]"
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#check smallest two for overlap\n",
    "small_overlap.loc[small_overlap[\"record_number\"].isin([2553977, 2552371])]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These do not seem to overlap. Instead, they seem to duplicate within each record.\n",
    "\n",
    "Likely there is duplication introduced also in record 5526257."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Record 5526257 uniqueness: 10\n",
      "Records 255.. uniqueness: 5\n"
     ]
    }
   ],
   "source": [
    "rec_55 = small_overlap.loc[small_overlap[\"record_number\"] == 5526257]\n",
    "recs_255 = small_overlap.loc[small_overlap[\"record_number\"].isin([2553977, 2552371])]\n",
    "\n",
    "print(\"Record 5526257 uniqueness:\", rec_55.md5.nunique())\n",
    "print(\"Records 255.. uniqueness:\", recs_255.md5.nunique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [],
   "source": [
    "columns_55 = [\"CAMID\", \"filename\", \"View\", \"Taxonomic_Name\", \"Locality\", \"md5\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CAMID</th>\n",
       "      <th>filename</th>\n",
       "      <th>View</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>Locality</th>\n",
       "      <th>md5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>38765</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42597_CAM045009_d.CR2</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3aa4f36fe82bf582cdb09e22cf998ea0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38764</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42596_CAM045009_d.CR2</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3aa4f36fe82bf582cdb09e22cf998ea0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39189</th>\n",
       "      <td>CAM045114</td>\n",
       "      <td>43024_CAM045114_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>46264ce1e0e5bd93735534c8cdc3a9fb</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39193</th>\n",
       "      <td>CAM045114</td>\n",
       "      <td>43025_CAM045114_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>46264ce1e0e5bd93735534c8cdc3a9fb</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38755</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42587_CAM045006_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5c71b211545b1b469dfadb06b35ccd57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38750</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42586_CAM045006_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5c71b211545b1b469dfadb06b35ccd57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38770</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42602_CAM045009_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6e1c1b698bbafe5fe686c00f93991759</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38771</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42603_CAM045009_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6e1c1b698bbafe5fe686c00f93991759</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38754</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42585_CAM045006_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7f09b3de42a6771d0ac63bee6995bc49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38753</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42584_CAM045006_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7f09b3de42a6771d0ac63bee6995bc49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38752</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42583_CAM045006_d.CR2</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>b146797ff261debef1f8ae93ce528817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38751</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42582_CAM045006_d.CR2</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>b146797ff261debef1f8ae93ce528817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38766</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42598_CAM045009_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>bd26f12f1fb204c623ff9fd615d6a0fd</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38767</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42599_CAM045009_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>bd26f12f1fb204c623ff9fd615d6a0fd</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39192</th>\n",
       "      <td>CAM045114</td>\n",
       "      <td>43023_CAM045114_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>db4c1d373140cd4e56f0976a88b0ab54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39191</th>\n",
       "      <td>CAM045114</td>\n",
       "      <td>43022_CAM045114_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>db4c1d373140cd4e56f0976a88b0ab54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38768</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42600_CAM045009_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>e9acf59ae9d96564f5cd8342281e4514</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38769</th>\n",
       "      <td>CAM045009</td>\n",
       "      <td>42601_CAM045009_v.CR2</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>e9acf59ae9d96564f5cd8342281e4514</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38756</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42588_CAM045006_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>f64512f4ce131775f3594e96ba761fa9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38757</th>\n",
       "      <td>CAM045006</td>\n",
       "      <td>42589_CAM045006_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius erato ssp. cyrbia</td>\n",
       "      <td>NaN</td>\n",
       "      <td>f64512f4ce131775f3594e96ba761fa9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID               filename     View  \\\n",
       "38765  CAM045009  42597_CAM045009_d.CR2   dorsal   \n",
       "38764  CAM045009  42596_CAM045009_d.CR2   dorsal   \n",
       "39189  CAM045114  43024_CAM045114_v.JPG  ventral   \n",
       "39193  CAM045114  43025_CAM045114_v.JPG  ventral   \n",
       "38755  CAM045006  42587_CAM045006_v.CR2  ventral   \n",
       "38750  CAM045006  42586_CAM045006_v.CR2  ventral   \n",
       "38770  CAM045009  42602_CAM045009_v.JPG  ventral   \n",
       "38771  CAM045009  42603_CAM045009_v.JPG  ventral   \n",
       "38754  CAM045006  42585_CAM045006_d.JPG   dorsal   \n",
       "38753  CAM045006  42584_CAM045006_d.JPG   dorsal   \n",
       "38752  CAM045006  42583_CAM045006_d.CR2   dorsal   \n",
       "38751  CAM045006  42582_CAM045006_d.CR2   dorsal   \n",
       "38766  CAM045009  42598_CAM045009_d.JPG   dorsal   \n",
       "38767  CAM045009  42599_CAM045009_d.JPG   dorsal   \n",
       "39192  CAM045114  43023_CAM045114_v.CR2  ventral   \n",
       "39191  CAM045114  43022_CAM045114_v.CR2  ventral   \n",
       "38768  CAM045009  42600_CAM045009_v.CR2  ventral   \n",
       "38769  CAM045009  42601_CAM045009_v.CR2  ventral   \n",
       "38756  CAM045006  42588_CAM045006_v.JPG  ventral   \n",
       "38757  CAM045006  42589_CAM045006_v.JPG  ventral   \n",
       "\n",
       "                     Taxonomic_Name Locality                               md5  \n",
       "38765  Heliconius erato ssp. cyrbia      NaN  3aa4f36fe82bf582cdb09e22cf998ea0  \n",
       "38764  Heliconius erato ssp. cyrbia      NaN  3aa4f36fe82bf582cdb09e22cf998ea0  \n",
       "39189  Heliconius erato ssp. cyrbia      NaN  46264ce1e0e5bd93735534c8cdc3a9fb  \n",
       "39193  Heliconius erato ssp. cyrbia      NaN  46264ce1e0e5bd93735534c8cdc3a9fb  \n",
       "38755  Heliconius erato ssp. cyrbia      NaN  5c71b211545b1b469dfadb06b35ccd57  \n",
       "38750  Heliconius erato ssp. cyrbia      NaN  5c71b211545b1b469dfadb06b35ccd57  \n",
       "38770  Heliconius erato ssp. cyrbia      NaN  6e1c1b698bbafe5fe686c00f93991759  \n",
       "38771  Heliconius erato ssp. cyrbia      NaN  6e1c1b698bbafe5fe686c00f93991759  \n",
       "38754  Heliconius erato ssp. cyrbia      NaN  7f09b3de42a6771d0ac63bee6995bc49  \n",
       "38753  Heliconius erato ssp. cyrbia      NaN  7f09b3de42a6771d0ac63bee6995bc49  \n",
       "38752  Heliconius erato ssp. cyrbia      NaN  b146797ff261debef1f8ae93ce528817  \n",
       "38751  Heliconius erato ssp. cyrbia      NaN  b146797ff261debef1f8ae93ce528817  \n",
       "38766  Heliconius erato ssp. cyrbia      NaN  bd26f12f1fb204c623ff9fd615d6a0fd  \n",
       "38767  Heliconius erato ssp. cyrbia      NaN  bd26f12f1fb204c623ff9fd615d6a0fd  \n",
       "39192  Heliconius erato ssp. cyrbia      NaN  db4c1d373140cd4e56f0976a88b0ab54  \n",
       "39191  Heliconius erato ssp. cyrbia      NaN  db4c1d373140cd4e56f0976a88b0ab54  \n",
       "38768  Heliconius erato ssp. cyrbia      NaN  e9acf59ae9d96564f5cd8342281e4514  \n",
       "38769  Heliconius erato ssp. cyrbia      NaN  e9acf59ae9d96564f5cd8342281e4514  \n",
       "38756  Heliconius erato ssp. cyrbia      NaN  f64512f4ce131775f3594e96ba761fa9  \n",
       "38757  Heliconius erato ssp. cyrbia      NaN  f64512f4ce131775f3594e96ba761fa9  "
      ]
     },
     "execution_count": 142,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_55[columns_55].sort_values(by = \"md5\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These are all exact duplicates..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False    10\n",
       "True     10\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 143,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_55.duplicated([\"CAMID\", \"Image_name\", \"View\", \"Taxonomic_Name\", \"Locality\", \"md5\"], keep = \"first\").value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>CAMID</th>\n",
       "      <th>filename</th>\n",
       "      <th>View</th>\n",
       "      <th>Taxonomic_Name</th>\n",
       "      <th>Locality</th>\n",
       "      <th>md5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>40141</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26197_CAM050147_DS1_HW_IMG_8537_cut_3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>21e726df7076f5c13fe1441126bac4d5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40144</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26196_CAM050147_DS1_HW_IMG_8537_cut_3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>21e726df7076f5c13fe1441126bac4d5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40112</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26102_CAM050036_S1_9_FW_IMG_8547_wb_2.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>34adbd5596f977834fb2c6876d2f4493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40116</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26115_CAM050036_S1_9_FW_IMG_8547_cut_2.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>34adbd5596f977834fb2c6876d2f4493</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40138</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26112_CAM050147_DS1_IMG_8513_4.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>464801449aa127933d9619cb4e6f0a01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40145</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26117_CAM050147_DS1_FW_IMG_8513_cut_4.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Madingley</td>\n",
       "      <td>464801449aa127933d9619cb4e6f0a01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40113</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>6d63d659fbc02369010938bbc229ad4d</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40120</th>\n",
       "      <td>CAM050036</td>\n",
       "      <td>26116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sara ssp. sara</td>\n",
       "      <td>Gamboa_insectaries</td>\n",
       "      <td>6d63d659fbc02369010938bbc229ad4d</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11978</th>\n",
       "      <td>CAM010354</td>\n",
       "      <td>23471_10354d.jpg</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>Heliconius sp.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>84d4ac6527458786cdb33166cd80e0a8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12010</th>\n",
       "      <td>CAM010362</td>\n",
       "      <td>23484_10362v.jpg</td>\n",
       "      <td>ventral</td>\n",
       "      <td>Heliconius sp.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>84d4ac6527458786cdb33166cd80e0a8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID                                       filename     View  \\\n",
       "40141  CAM050147      26197_CAM050147_DS1_HW_IMG_8537_cut_3.tif   dorsal   \n",
       "40144  CAM050147      26196_CAM050147_DS1_HW_IMG_8537_cut_3.tif   dorsal   \n",
       "40112  CAM050036      26102_CAM050036_S1_9_FW_IMG_8547_wb_2.tif   dorsal   \n",
       "40116  CAM050036     26115_CAM050036_S1_9_FW_IMG_8547_cut_2.tif   dorsal   \n",
       "40138  CAM050147             26112_CAM050147_DS1_IMG_8513_4.tif   dorsal   \n",
       "40145  CAM050147      26117_CAM050147_DS1_FW_IMG_8513_cut_4.tif   dorsal   \n",
       "40113  CAM050036   26105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif   dorsal   \n",
       "40120  CAM050036  26116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif   dorsal   \n",
       "11978  CAM010354                               23471_10354d.jpg   dorsal   \n",
       "12010  CAM010362                               23484_10362v.jpg  ventral   \n",
       "\n",
       "                  Taxonomic_Name            Locality  \\\n",
       "40141  Heliconius sara ssp. sara           Madingley   \n",
       "40144  Heliconius sara ssp. sara           Madingley   \n",
       "40112  Heliconius sara ssp. sara  Gamboa_insectaries   \n",
       "40116  Heliconius sara ssp. sara  Gamboa_insectaries   \n",
       "40138  Heliconius sara ssp. sara           Madingley   \n",
       "40145  Heliconius sara ssp. sara           Madingley   \n",
       "40113  Heliconius sara ssp. sara  Gamboa_insectaries   \n",
       "40120  Heliconius sara ssp. sara  Gamboa_insectaries   \n",
       "11978             Heliconius sp.                 NaN   \n",
       "12010             Heliconius sp.                 NaN   \n",
       "\n",
       "                                    md5  \n",
       "40141  21e726df7076f5c13fe1441126bac4d5  \n",
       "40144  21e726df7076f5c13fe1441126bac4d5  \n",
       "40112  34adbd5596f977834fb2c6876d2f4493  \n",
       "40116  34adbd5596f977834fb2c6876d2f4493  \n",
       "40138  464801449aa127933d9619cb4e6f0a01  \n",
       "40145  464801449aa127933d9619cb4e6f0a01  \n",
       "40113  6d63d659fbc02369010938bbc229ad4d  \n",
       "40120  6d63d659fbc02369010938bbc229ad4d  \n",
       "11978  84d4ac6527458786cdb33166cd80e0a8  \n",
       "12010  84d4ac6527458786cdb33166cd80e0a8  "
      ]
     },
     "execution_count": 148,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "recs_255[columns_55].sort_values(by = \"md5\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These have mismatched filenames and even mismatched CAMIDs for record 2552371.\n",
    "\n",
    "The first 8 are all cropped close-ups of a single wing, so don't seem particularly helpful for our use-cases. Will keep the ones with `cut_` in the name, as some of this duplication seems to be from errors in image naming (the view also is inconsistent since it's a crop of a single wing).\n",
    "\n",
    "The last two are unspecified species. The image is definitely dorsal, but there is no indication of which specimen it is, so both records must be removed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "std",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}