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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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "jiggins = pd.read_csv(\"../metadata/Jiggins_Zenodo_Master.csv\", low_memory = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(49956, 25)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "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>Unnamed: 0</th>\n",
       "      <th>CAMID</th>\n",
       "      <th>X</th>\n",
       "      <th>Image_name</th>\n",
       "      <th>Side</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>...</th>\n",
       "      <th>Dataset</th>\n",
       "      <th>Store</th>\n",
       "      <th>Eclosion.Date</th>\n",
       "      <th>Brood</th>\n",
       "      <th>Death.Date</th>\n",
       "      <th>Cross.Type</th>\n",
       "      <th>Stage</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Unit.Type</th>\n",
       "      <th>Verbatim.Coordinates</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20776</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.sheffield.ps.nn.ikiam.batch1.csv</td>\n",
       "      <td>https://zenodo.org/record/4288311</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20777</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.sheffield.ps.nn.ikiam.batch1.csv</td>\n",
       "      <td>https://zenodo.org/record/4288311</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20778</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.sheffield.ps.nn.ikiam.batch1.csv</td>\n",
       "      <td>https://zenodo.org/record/4288311</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20779</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.sheffield.ps.nn.ikiam.batch1.csv</td>\n",
       "      <td>https://zenodo.org/record/4288311</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>20780</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.sheffield.ps.nn.ikiam.batch1.csv</td>\n",
       "      <td>https://zenodo.org/record/4288311</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 25 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0 CAMID      X Image_name Side  \\\n",
       "0           1   NaN  20776        NaN  NaN   \n",
       "1           2   NaN  20777        NaN  NaN   \n",
       "2           3   NaN  20778        NaN  NaN   \n",
       "3           4   NaN  20779        NaN  NaN   \n",
       "4           5   NaN  20780        NaN  NaN   \n",
       "\n",
       "                          zenodo_name                        zenodo_link  \\\n",
       "0  0.sheffield.ps.nn.ikiam.batch1.csv  https://zenodo.org/record/4288311   \n",
       "1  0.sheffield.ps.nn.ikiam.batch1.csv  https://zenodo.org/record/4288311   \n",
       "2  0.sheffield.ps.nn.ikiam.batch1.csv  https://zenodo.org/record/4288311   \n",
       "3  0.sheffield.ps.nn.ikiam.batch1.csv  https://zenodo.org/record/4288311   \n",
       "4  0.sheffield.ps.nn.ikiam.batch1.csv  https://zenodo.org/record/4288311   \n",
       "\n",
       "  Sequence Taxonomic.Name Locality  ... Dataset Store Eclosion.Date  Brood  \\\n",
       "0      NaN            NaN      NaN  ...     NaN   NaN           NaN    NaN   \n",
       "1      NaN            NaN      NaN  ...     NaN   NaN           NaN    NaN   \n",
       "2      NaN            NaN      NaN  ...     NaN   NaN           NaN    NaN   \n",
       "3      NaN            NaN      NaN  ...     NaN   NaN           NaN    NaN   \n",
       "4      NaN            NaN      NaN  ...     NaN   NaN           NaN    NaN   \n",
       "\n",
       "  Death.Date Cross.Type Stage  Sex Unit.Type Verbatim.Coordinates  \n",
       "0        NaN        NaN   NaN  NaN       NaN                  NaN  \n",
       "1        NaN        NaN   NaN  NaN       NaN                  NaN  \n",
       "2        NaN        NaN   NaN  NaN       NaN                  NaN  \n",
       "3        NaN        NaN   NaN  NaN       NaN                  NaN  \n",
       "4        NaN        NaN   NaN  NaN       NaN                  NaN  \n",
       "\n",
       "[5 rows x 25 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Unnamed: 0', 'CAMID', 'X', 'Image_name', 'Side', 'zenodo_name',\n",
       "       'zenodo_link', 'Sequence', 'Taxonomic.Name', 'Locality',\n",
       "       'Sample.accession', 'Collected.by', 'Other.Id', 'Collected.By', 'Date',\n",
       "       'Dataset', 'Store', 'Eclosion.Date', 'Brood', 'Death.Date',\n",
       "       'Cross.Type', 'Stage', 'Sex', 'Unit.Type', 'Verbatim.Coordinates'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "411"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins.Image_name.isna().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "28585                  CAM036108_v.JPG\n",
       "45469                  CAM044420_v.CR2\n",
       "16097                  CAM011543_v.CR2\n",
       "22992                  CAM017525_v.JPG\n",
       "6601                   CAM000930_v.JPG\n",
       "39261                  CAM043354_v.CR2\n",
       "2577                     19N2059_d.CR2\n",
       "21344                  CAM017153_d.JPG\n",
       "48669                   CS004036_d.JPG\n",
       "19706                  CAM016699_v.JPG\n",
       "12020                  CAM009527_v.JPG\n",
       "47898                   CS000628_d.JPG\n",
       "7592                   CAM001394_d.JPG\n",
       "43523                  CAM044173_v.CR2\n",
       "12596                  CAM010226_v.JPG\n",
       "33816                  CAM041028_v.JPG\n",
       "23148    CAM017547_v_whitestandard.JPG\n",
       "44996                CAM044362_hwv.CR2\n",
       "3460                     19N2605_v.JPG\n",
       "24164    CAM017738_d_whitestandard.CR2\n",
       "Name: Image_name, dtype: object"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins.Image_name.sample(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "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>zenodo_name</th>\n",
       "      <th>zenodo_link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>22895</th>\n",
       "      <td>CAM017512</td>\n",
       "      <td>5226</td>\n",
       "      <td>CAM017512_d.JPG</td>\n",
       "      <td>CAM.coll.images.batch1_v2.csv</td>\n",
       "      <td>https://zenodo.org/record/3082688</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36246</th>\n",
       "      <td>CAM041681</td>\n",
       "      <td>39690</td>\n",
       "      <td>CAM041681_d.CR2</td>\n",
       "      <td>0.gmk.broods.all.csv</td>\n",
       "      <td>https://zenodo.org/record/4291095</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>38630</th>\n",
       "      <td>CAM043178</td>\n",
       "      <td>29793</td>\n",
       "      <td>CAM043178_fwv.CR2</td>\n",
       "      <td>batch1.Peru.image.names.Zenodo.csv</td>\n",
       "      <td>https://zenodo.org/record/3569598</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45984</th>\n",
       "      <td>CAM044484</td>\n",
       "      <td>34635</td>\n",
       "      <td>CAM044484_hwd.CR2</td>\n",
       "      <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
       "      <td>https://zenodo.org/record/4287444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15393</th>\n",
       "      <td>CAM011382</td>\n",
       "      <td>28038</td>\n",
       "      <td>CAM011382_d.JPG</td>\n",
       "      <td>2001_2.broods.batch.2.csv</td>\n",
       "      <td>https://zenodo.org/record/2550097</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44443</th>\n",
       "      <td>CAM044299</td>\n",
       "      <td>33864</td>\n",
       "      <td>CAM044299_d.JPG</td>\n",
       "      <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
       "      <td>https://zenodo.org/record/4287444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>CAM001175</td>\n",
       "      <td>7908</td>\n",
       "      <td>CAM001175_d.JPG</td>\n",
       "      <td>CAM.coll.images.batch4.csv</td>\n",
       "      <td>https://zenodo.org/record/2682669</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID      X         Image_name  \\\n",
       "22895  CAM017512   5226    CAM017512_d.JPG   \n",
       "36246  CAM041681  39690    CAM041681_d.CR2   \n",
       "38630  CAM043178  29793  CAM043178_fwv.CR2   \n",
       "45984  CAM044484  34635  CAM044484_hwd.CR2   \n",
       "15393  CAM011382  28038    CAM011382_d.JPG   \n",
       "44443  CAM044299  33864    CAM044299_d.JPG   \n",
       "7117   CAM001175   7908    CAM001175_d.JPG   \n",
       "\n",
       "                              zenodo_name                        zenodo_link  \n",
       "22895       CAM.coll.images.batch1_v2.csv  https://zenodo.org/record/3082688  \n",
       "36246                0.gmk.broods.all.csv  https://zenodo.org/record/4291095  \n",
       "38630  batch1.Peru.image.names.Zenodo.csv  https://zenodo.org/record/3569598  \n",
       "45984  batch2.Peru.image.names.Zenodo.csv  https://zenodo.org/record/4287444  \n",
       "15393           2001_2.broods.batch.2.csv  https://zenodo.org/record/2550097  \n",
       "44443  batch2.Peru.image.names.Zenodo.csv  https://zenodo.org/record/4287444  \n",
       "7117           CAM.coll.images.batch4.csv  https://zenodo.org/record/2682669  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins_imgs = jiggins[['CAMID', 'X', 'Image_name', 'zenodo_name', 'zenodo_link']].dropna()\n",
    "jiggins_imgs.sample(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "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>zenodo_name</th>\n",
       "      <th>zenodo_link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10528</th>\n",
       "      <td>CAM008821</td>\n",
       "      <td>9887</td>\n",
       "      <td>CAM008821_d.JPG</td>\n",
       "      <td>CAM.coll.images.batch6.csv</td>\n",
       "      <td>https://zenodo.org/record/2686762</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19587</th>\n",
       "      <td>CAM016660</td>\n",
       "      <td>3856</td>\n",
       "      <td>CAM016660_v.JPG</td>\n",
       "      <td>CAM.coll.images.batch1_v2.csv</td>\n",
       "      <td>https://zenodo.org/record/3082688</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25858</th>\n",
       "      <td>CAM017989</td>\n",
       "      <td>17211</td>\n",
       "      <td>CAM017989_v_whitestandard.JPG</td>\n",
       "      <td>CAM.coll.patricio.batch1.csv</td>\n",
       "      <td>https://zenodo.org/record/1748277</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10042</th>\n",
       "      <td>CAM008668</td>\n",
       "      <td>46436</td>\n",
       "      <td>CAM008668_d.JPG</td>\n",
       "      <td>occurences_and_multimedia.csv</td>\n",
       "      <td>https://zenodo.org/record/3477891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30646</th>\n",
       "      <td>CAM040217</td>\n",
       "      <td>47915</td>\n",
       "      <td>CAM040217_v.JPG</td>\n",
       "      <td>occurences_and_multimedia.csv</td>\n",
       "      <td>https://zenodo.org/record/3477891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42889</th>\n",
       "      <td>CAM044091</td>\n",
       "      <td>33084</td>\n",
       "      <td>CAM044091_fwd.JPG</td>\n",
       "      <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
       "      <td>https://zenodo.org/record/4287444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39215</th>\n",
       "      <td>CAM043344</td>\n",
       "      <td>30372</td>\n",
       "      <td>CAM043344_fwd.JPG</td>\n",
       "      <td>batch1.Peru.image.names.Zenodo.csv</td>\n",
       "      <td>https://zenodo.org/record/3569598</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID      X                     Image_name  \\\n",
       "10528  CAM008821   9887                CAM008821_d.JPG   \n",
       "19587  CAM016660   3856                CAM016660_v.JPG   \n",
       "25858  CAM017989  17211  CAM017989_v_whitestandard.JPG   \n",
       "10042  CAM008668  46436                CAM008668_d.JPG   \n",
       "30646  CAM040217  47915                CAM040217_v.JPG   \n",
       "42889  CAM044091  33084              CAM044091_fwd.JPG   \n",
       "39215  CAM043344  30372              CAM043344_fwd.JPG   \n",
       "\n",
       "                              zenodo_name                        zenodo_link  \n",
       "10528          CAM.coll.images.batch6.csv  https://zenodo.org/record/2686762  \n",
       "19587       CAM.coll.images.batch1_v2.csv  https://zenodo.org/record/3082688  \n",
       "25858        CAM.coll.patricio.batch1.csv  https://zenodo.org/record/1748277  \n",
       "10042       occurences_and_multimedia.csv  https://zenodo.org/record/3477891  \n",
       "30646       occurences_and_multimedia.csv  https://zenodo.org/record/3477891  \n",
       "42889  batch2.Peru.image.names.Zenodo.csv  https://zenodo.org/record/4287444  \n",
       "39215  batch1.Peru.image.names.Zenodo.csv  https://zenodo.org/record/3569598  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins_imgs[jiggins_imgs.Image_name.str.contains('JPG')].sample(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "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>zenodo_name</th>\n",
       "      <th>zenodo_link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>8296</th>\n",
       "      <td>CAM008147</td>\n",
       "      <td>44302</td>\n",
       "      <td>8147v.jpg</td>\n",
       "      <td>occurences_and_multimedia.csv</td>\n",
       "      <td>https://zenodo.org/record/3477891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15626</th>\n",
       "      <td>CAM011437</td>\n",
       "      <td>44275</td>\n",
       "      <td>11437v.jpg</td>\n",
       "      <td>occurences_and_multimedia.csv</td>\n",
       "      <td>https://zenodo.org/record/3477891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16975</th>\n",
       "      <td>CAM012169</td>\n",
       "      <td>25057</td>\n",
       "      <td>12169v.jpg</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
       "      <td>https://zenodo.org/record/2552371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14097</th>\n",
       "      <td>CAM010773</td>\n",
       "      <td>23942</td>\n",
       "      <td>10773v.jpg</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
       "      <td>https://zenodo.org/record/2552371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15970</th>\n",
       "      <td>CAM011513</td>\n",
       "      <td>24565</td>\n",
       "      <td>11513v.jpg</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
       "      <td>https://zenodo.org/record/2552371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13349</th>\n",
       "      <td>CAM010485</td>\n",
       "      <td>23640</td>\n",
       "      <td>10485d.jpg</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
       "      <td>https://zenodo.org/record/2552371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16919</th>\n",
       "      <td>CAM012124</td>\n",
       "      <td>25001</td>\n",
       "      <td>12124v.jpg</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part1.csv</td>\n",
       "      <td>https://zenodo.org/record/2552371</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID      X  Image_name  \\\n",
       "8296   CAM008147  44302   8147v.jpg   \n",
       "15626  CAM011437  44275  11437v.jpg   \n",
       "16975  CAM012169  25057  12169v.jpg   \n",
       "14097  CAM010773  23942  10773v.jpg   \n",
       "15970  CAM011513  24565  11513v.jpg   \n",
       "13349  CAM010485  23640  10485d.jpg   \n",
       "16919  CAM012124  25001  12124v.jpg   \n",
       "\n",
       "                                          zenodo_name  \\\n",
       "8296                    occurences_and_multimedia.csv   \n",
       "15626                   occurences_and_multimedia.csv   \n",
       "16975  Heliconius_wing_old_photos_2001_2019_part1.csv   \n",
       "14097  Heliconius_wing_old_photos_2001_2019_part1.csv   \n",
       "15970  Heliconius_wing_old_photos_2001_2019_part1.csv   \n",
       "13349  Heliconius_wing_old_photos_2001_2019_part1.csv   \n",
       "16919  Heliconius_wing_old_photos_2001_2019_part1.csv   \n",
       "\n",
       "                             zenodo_link  \n",
       "8296   https://zenodo.org/record/3477891  \n",
       "15626  https://zenodo.org/record/3477891  \n",
       "16975  https://zenodo.org/record/2552371  \n",
       "14097  https://zenodo.org/record/2552371  \n",
       "15970  https://zenodo.org/record/2552371  \n",
       "13349  https://zenodo.org/record/2552371  \n",
       "16919  https://zenodo.org/record/2552371  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins_imgs[jiggins_imgs.Image_name.str.contains('jpg')].sample(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "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>zenodo_name</th>\n",
       "      <th>zenodo_link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>47693</th>\n",
       "      <td>CAM050052</td>\n",
       "      <td>26152</td>\n",
       "      <td>CAM050052_M1_10_Hmr_mut_D_cut.tif</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47694</th>\n",
       "      <td>CAM050063</td>\n",
       "      <td>26155</td>\n",
       "      <td>CAM050063_M7_17_Hmr_mut_V_IMG_8293_wb_cut.tif</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47712</th>\n",
       "      <td>CAM050147</td>\n",
       "      <td>26197</td>\n",
       "      <td>CAM050147_DS1_HW_IMG_8537_cut_3.tif</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47637</th>\n",
       "      <td>CAM050006</td>\n",
       "      <td>26126</td>\n",
       "      <td>CAM050006_S1_17_Hsar_mut_V_8296_wb_cut.tif</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47626</th>\n",
       "      <td>CAM050001</td>\n",
       "      <td>26118</td>\n",
       "      <td>CAM050001_S1_5_Hs_mut_D_wb_cut.tif</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47692</th>\n",
       "      <td>CAM050052</td>\n",
       "      <td>26153</td>\n",
       "      <td>CAM050052_M1_10_Hmr_mut_V_cut.tif</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47673</th>\n",
       "      <td>CAM050026</td>\n",
       "      <td>26147</td>\n",
       "      <td>CAM050026_S4_1_Hs_mut_V_IMG_8453_wb_cut.tif</td>\n",
       "      <td>Heliconius_wing_old_photos_2001_2019_part3.csv</td>\n",
       "      <td>https://zenodo.org/record/2553977</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID      X                                     Image_name  \\\n",
       "47693  CAM050052  26152              CAM050052_M1_10_Hmr_mut_D_cut.tif   \n",
       "47694  CAM050063  26155  CAM050063_M7_17_Hmr_mut_V_IMG_8293_wb_cut.tif   \n",
       "47712  CAM050147  26197            CAM050147_DS1_HW_IMG_8537_cut_3.tif   \n",
       "47637  CAM050006  26126     CAM050006_S1_17_Hsar_mut_V_8296_wb_cut.tif   \n",
       "47626  CAM050001  26118             CAM050001_S1_5_Hs_mut_D_wb_cut.tif   \n",
       "47692  CAM050052  26153              CAM050052_M1_10_Hmr_mut_V_cut.tif   \n",
       "47673  CAM050026  26147    CAM050026_S4_1_Hs_mut_V_IMG_8453_wb_cut.tif   \n",
       "\n",
       "                                          zenodo_name  \\\n",
       "47693  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "47694  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "47712  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "47637  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "47626  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "47692  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "47673  Heliconius_wing_old_photos_2001_2019_part3.csv   \n",
       "\n",
       "                             zenodo_link  \n",
       "47693  https://zenodo.org/record/2553977  \n",
       "47694  https://zenodo.org/record/2553977  \n",
       "47712  https://zenodo.org/record/2553977  \n",
       "47637  https://zenodo.org/record/2553977  \n",
       "47626  https://zenodo.org/record/2553977  \n",
       "47692  https://zenodo.org/record/2553977  \n",
       "47673  https://zenodo.org/record/2553977  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins_imgs[jiggins_imgs.Image_name.str.contains('tif')].sample(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "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>zenodo_name</th>\n",
       "      <th>zenodo_link</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>42543</th>\n",
       "      <td>CAM044049</td>\n",
       "      <td>32915</td>\n",
       "      <td>CAM044049_d.CR2</td>\n",
       "      <td>batch2.Peru.image.names.Zenodo.csv</td>\n",
       "      <td>https://zenodo.org/record/4287444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44160</th>\n",
       "      <td>CAM044261</td>\n",
       "      <td>36392</td>\n",
       "      <td>CAM044261_d.JPG</td>\n",
       "      <td>batch3.Peru.image.names.Zenodo.csv</td>\n",
       "      <td>https://zenodo.org/record/4288250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14298</th>\n",
       "      <td>CAM010848</td>\n",
       "      <td>27458</td>\n",
       "      <td>CAM010848_d.JPG</td>\n",
       "      <td>2001_2.broods.batch.1.csv</td>\n",
       "      <td>https://zenodo.org/record/2549524</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19141</th>\n",
       "      <td>CAM016524</td>\n",
       "      <td>759</td>\n",
       "      <td>CAM016524_d.JPG</td>\n",
       "      <td>CAM.coll.images.batch1.csv</td>\n",
       "      <td>https://zenodo.org/record/1247307</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3229</th>\n",
       "      <td>19N2383</td>\n",
       "      <td>22175</td>\n",
       "      <td>19N2383_d.JPG</td>\n",
       "      <td>0.sheffield.ps.nn.ikiam.batch2.csv</td>\n",
       "      <td>https://zenodo.org/record/4288311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34948</th>\n",
       "      <td>CAM041352</td>\n",
       "      <td>14340</td>\n",
       "      <td>CAM041352_d.JPG</td>\n",
       "      <td>CAM.coll.images.batch9.csv</td>\n",
       "      <td>https://zenodo.org/record/2714333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28072</th>\n",
       "      <td>CAM021080</td>\n",
       "      <td>11587</td>\n",
       "      <td>CAM021080_d.JPG</td>\n",
       "      <td>CAM.coll.images.batch7.csv</td>\n",
       "      <td>https://zenodo.org/record/2702457</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           CAMID      X       Image_name                         zenodo_name  \\\n",
       "42543  CAM044049  32915  CAM044049_d.CR2  batch2.Peru.image.names.Zenodo.csv   \n",
       "44160  CAM044261  36392  CAM044261_d.JPG  batch3.Peru.image.names.Zenodo.csv   \n",
       "14298  CAM010848  27458  CAM010848_d.JPG           2001_2.broods.batch.1.csv   \n",
       "19141  CAM016524    759  CAM016524_d.JPG          CAM.coll.images.batch1.csv   \n",
       "3229     19N2383  22175    19N2383_d.JPG  0.sheffield.ps.nn.ikiam.batch2.csv   \n",
       "34948  CAM041352  14340  CAM041352_d.JPG          CAM.coll.images.batch9.csv   \n",
       "28072  CAM021080  11587  CAM021080_d.JPG          CAM.coll.images.batch7.csv   \n",
       "\n",
       "                             zenodo_link  \n",
       "42543  https://zenodo.org/record/4287444  \n",
       "44160  https://zenodo.org/record/4288250  \n",
       "14298  https://zenodo.org/record/2549524  \n",
       "19141  https://zenodo.org/record/1247307  \n",
       "3229   https://zenodo.org/record/4288311  \n",
       "34948  https://zenodo.org/record/2714333  \n",
       "28072  https://zenodo.org/record/2702457  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jiggins_imgs[jiggins_imgs.Image_name.str.contains('d.')].sample(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'JPG', 'CR2', 'tif', 'jpeg', 'JPG(1)', 'jpg'}\n"
     ]
    }
   ],
   "source": [
    "check_filetypes = []\n",
    "for img_name in list(jiggins_imgs.Image_name.unique()):\n",
    "    check_filetypes.append(img_name.split(\".\")[1])\n",
    "\n",
    "print(set(check_filetypes))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Note CR2 is raw, may be duplicates, would need conversion\n",
    "file_types = [\"JPG\", \"jpg\", \"jpeg\", \"tif\", \"JPG(1)\", \"CR2\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "37821"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "images = []\n",
    "\n",
    "for img_name in list(jiggins_imgs.Image_name.unique()):\n",
    "    if img_name.split(\".\")[1] in file_types:\n",
    "        images.append(img_name)\n",
    "\n",
    "len(images)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 49359 entries, 433 to 49791\n",
      "Data columns (total 5 columns):\n",
      " #   Column       Non-Null Count  Dtype \n",
      "---  ------       --------------  ----- \n",
      " 0   CAMID        49359 non-null  object\n",
      " 1   X            49359 non-null  int64 \n",
      " 2   Image_name   49359 non-null  object\n",
      " 3   zenodo_name  49359 non-null  object\n",
      " 4   zenodo_link  49359 non-null  object\n",
      "dtypes: int64(1), object(4)\n",
      "memory usage: 2.3+ MB\n"
     ]
    }
   ],
   "source": [
    "img = jiggins_imgs[jiggins_imgs.Image_name.isin(images)]\n",
    "img.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_file_type(filename):\n",
    "    jpgs = [\"JPG\", \"jpg\", \"jpeg\", \"JPG(1)\"]\n",
    "    file_type = filename.split(\".\")[1]\n",
    "    if file_type in jpgs:\n",
    "        return \"jpg\"\n",
    "    elif file_type == \"tif\":\n",
    "        return \"tif\"\n",
    "    elif file_type == \"CR2\":\n",
    "        return \"raw\"\n",
    "    else:\n",
    "        print(f\"{file_type} does not match known file types\")\n",
    "        return None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 49359 entries, 433 to 49791\n",
      "Data columns (total 6 columns):\n",
      " #   Column       Non-Null Count  Dtype \n",
      "---  ------       --------------  ----- \n",
      " 0   CAMID        49359 non-null  object\n",
      " 1   X            49359 non-null  int64 \n",
      " 2   Image_name   49359 non-null  object\n",
      " 3   zenodo_name  49359 non-null  object\n",
      " 4   zenodo_link  49359 non-null  object\n",
      " 5   file_type    49359 non-null  object\n",
      "dtypes: int64(1), object(5)\n",
      "memory usage: 2.6+ MB\n"
     ]
    }
   ],
   "source": [
    "img[\"file_type\"] = img[\"Image_name\"].apply(get_file_type)\n",
    "img.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "img.to_csv(\"../zendo_img_master.csv\", index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Unnamed: 0    49956\n",
      "CAMID         12586\n",
      "X             49956\n",
      "Image_name    37843\n",
      "dtype: int64\n",
      "\n",
      "CAMID          12586\n",
      "X              49359\n",
      "Image_name     37821\n",
      "zenodo_name       36\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print(jiggins[list(jiggins.columns)[:4]].nunique())\n",
    "print()\n",
    "print(img[list(img.columns[:4])].nunique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 49956 entries, 0 to 49955\n",
      "Data columns (total 4 columns):\n",
      " #   Column      Non-Null Count  Dtype \n",
      "---  ------      --------------  ----- \n",
      " 0   Unnamed: 0  49956 non-null  int64 \n",
      " 1   CAMID       49359 non-null  object\n",
      " 2   X           49956 non-null  int64 \n",
      " 3   Image_name  49545 non-null  object\n",
      "dtypes: int64(2), object(2)\n",
      "memory usage: 1.5+ MB\n",
      "None\n",
      "\n",
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 49359 entries, 433 to 49791\n",
      "Data columns (total 4 columns):\n",
      " #   Column       Non-Null Count  Dtype \n",
      "---  ------       --------------  ----- \n",
      " 0   CAMID        49359 non-null  object\n",
      " 1   X            49359 non-null  int64 \n",
      " 2   Image_name   49359 non-null  object\n",
      " 3   zenodo_name  49359 non-null  object\n",
      "dtypes: int64(1), object(3)\n",
      "memory usage: 1.9+ MB\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "print(jiggins[list(jiggins.columns)[:4]].info())\n",
    "print()\n",
    "print(img[list(img.columns[:4])].info())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We want to match these up on `X`, since all entries have a value and it is unique."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 49359 entries, 433 to 49791\n",
      "Data columns (total 25 columns):\n",
      " #   Column                Non-Null Count  Dtype  \n",
      "---  ------                --------------  -----  \n",
      " 0   Unnamed: 0            49359 non-null  int64  \n",
      " 1   CAMID                 49359 non-null  object \n",
      " 2   X                     49359 non-null  int64  \n",
      " 3   Image_name            49359 non-null  object \n",
      " 4   Side                  48288 non-null  object \n",
      " 5   zenodo_name           49359 non-null  object \n",
      " 6   zenodo_link           49359 non-null  object \n",
      " 7   Sequence              48424 non-null  object \n",
      " 8   Taxonomic.Name        45473 non-null  object \n",
      " 9   Locality              34015 non-null  object \n",
      " 10  Sample.accession      5884 non-null   object \n",
      " 11  Collected.by          5280 non-null   object \n",
      " 12  Other.Id              14382 non-null  object \n",
      " 13  Collected.By          0 non-null      float64\n",
      " 14  Date                  33718 non-null  object \n",
      " 15  Dataset               40405 non-null  object \n",
      " 16  Store                 39485 non-null  object \n",
      " 17  Eclosion.Date         97 non-null     object \n",
      " 18  Brood                 14942 non-null  object \n",
      " 19  Death.Date            318 non-null    object \n",
      " 20  Cross.Type            5133 non-null   object \n",
      " 21  Stage                 15 non-null     object \n",
      " 22  Sex                   36243 non-null  object \n",
      " 23  Unit.Type             33890 non-null  object \n",
      " 24  Verbatim.Coordinates  0 non-null      float64\n",
      "dtypes: float64(2), int64(2), object(21)\n",
      "memory usage: 9.8+ MB\n"
     ]
    }
   ],
   "source": [
    "df_img = jiggins.loc[jiggins.X.isin(list(img.X))]\n",
    "df_img.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Rename columns to have underscore"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/3055364590.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\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",
      "  df_img.rename(columns = {\"Side\": \"View\",\n"
     ]
    }
   ],
   "source": [
    "df_img.rename(columns = {\"Side\": \"View\",\n",
    "                        \"Taxonomic.Name\": \"Taxonomic_Name\",\n",
    "                        \"Cross.Type\": \"Cross_Type\",\n",
    "                        \"Sample.accession\": \"Sample_accession\",\n",
    "                        \"Collected.by\": \"Collected_by\",\n",
    "                        \"Other.Id\": \"Other_ID\",\n",
    "                        \"Death.Date\": \"Death_Date\",\n",
    "                        \"Unit.Type\": \"Unit_Type\"},\n",
    "                        inplace = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "null_cols = [\"Unnamed: 0\", \"Collected.By\", \"Eclosion.Date\", \"Verbatim.Coordinates\"]\n",
    "non_null_cols = [col for col in list(df_img.columns) if col not in null_cols]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_img = df_img[non_null_cols]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "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>Other_ID</th>\n",
       "      <th>Date</th>\n",
       "      <th>Dataset</th>\n",
       "      <th>Store</th>\n",
       "      <th>Brood</th>\n",
       "      <th>Death_Date</th>\n",
       "      <th>Cross_Type</th>\n",
       "      <th>Stage</th>\n",
       "      <th>Sex</th>\n",
       "      <th>Unit_Type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>433</th>\n",
       "      <td>14N004</td>\n",
       "      <td>15131</td>\n",
       "      <td>14N004_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>0.4.nn.requests2.csv</td>\n",
       "      <td>https://zenodo.org/record/4289223</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Nadeau Sheffield</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>434</th>\n",
       "      <td>14N004</td>\n",
       "      <td>15132</td>\n",
       "      <td>14N004_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.4.nn.requests2.csv</td>\n",
       "      <td>https://zenodo.org/record/4289223</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Nadeau Sheffield</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>435</th>\n",
       "      <td>14N009</td>\n",
       "      <td>15134</td>\n",
       "      <td>14N009_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.4.nn.requests2.csv</td>\n",
       "      <td>https://zenodo.org/record/4289223</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Nadeau Sheffield</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436</th>\n",
       "      <td>14N009</td>\n",
       "      <td>15133</td>\n",
       "      <td>14N009_d.JPG</td>\n",
       "      <td>dorsal</td>\n",
       "      <td>0.4.nn.requests2.csv</td>\n",
       "      <td>https://zenodo.org/record/4289223</td>\n",
       "      <td>9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Nadeau Sheffield</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>437</th>\n",
       "      <td>14N014</td>\n",
       "      <td>15136</td>\n",
       "      <td>14N014_v.JPG</td>\n",
       "      <td>ventral</td>\n",
       "      <td>0.4.nn.requests2.csv</td>\n",
       "      <td>https://zenodo.org/record/4289223</td>\n",
       "      <td>14</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Nadeau Sheffield</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      CAMID      X    Image_name     View           zenodo_name  \\\n",
       "433  14N004  15131  14N004_d.JPG   dorsal  0.4.nn.requests2.csv   \n",
       "434  14N004  15132  14N004_v.JPG  ventral  0.4.nn.requests2.csv   \n",
       "435  14N009  15134  14N009_v.JPG  ventral  0.4.nn.requests2.csv   \n",
       "436  14N009  15133  14N009_d.JPG   dorsal  0.4.nn.requests2.csv   \n",
       "437  14N014  15136  14N014_v.JPG  ventral  0.4.nn.requests2.csv   \n",
       "\n",
       "                           zenodo_link Sequence Taxonomic_Name Locality  \\\n",
       "433  https://zenodo.org/record/4289223        4            NaN      NaN   \n",
       "434  https://zenodo.org/record/4289223        4            NaN      NaN   \n",
       "435  https://zenodo.org/record/4289223        9            NaN      NaN   \n",
       "436  https://zenodo.org/record/4289223        9            NaN      NaN   \n",
       "437  https://zenodo.org/record/4289223       14            NaN      NaN   \n",
       "\n",
       "    Sample_accession  ... Other_ID Date           Dataset Store Brood  \\\n",
       "433              NaN  ...      NaN  NaN  Nadeau Sheffield   NaN   NaN   \n",
       "434              NaN  ...      NaN  NaN  Nadeau Sheffield   NaN   NaN   \n",
       "435              NaN  ...      NaN  NaN  Nadeau Sheffield   NaN   NaN   \n",
       "436              NaN  ...      NaN  NaN  Nadeau Sheffield   NaN   NaN   \n",
       "437              NaN  ...      NaN  NaN  Nadeau Sheffield   NaN   NaN   \n",
       "\n",
       "    Death_Date Cross_Type Stage  Sex Unit_Type  \n",
       "433        NaN        NaN   NaN  NaN       NaN  \n",
       "434        NaN        NaN   NaN  NaN       NaN  \n",
       "435        NaN        NaN   NaN  NaN       NaN  \n",
       "436        NaN        NaN   NaN  NaN       NaN  \n",
       "437        NaN        NaN   NaN  NaN       NaN  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_img.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 49359 entries, 433 to 49791\n",
      "Data columns (total 22 columns):\n",
      " #   Column            Non-Null Count  Dtype \n",
      "---  ------            --------------  ----- \n",
      " 0   CAMID             49359 non-null  object\n",
      " 1   X                 49359 non-null  int64 \n",
      " 2   Image_name        49359 non-null  object\n",
      " 3   View              48288 non-null  object\n",
      " 4   zenodo_name       49359 non-null  object\n",
      " 5   zenodo_link       49359 non-null  object\n",
      " 6   Sequence          48424 non-null  object\n",
      " 7   Taxonomic_Name    45473 non-null  object\n",
      " 8   Locality          34015 non-null  object\n",
      " 9   Sample_accession  5884 non-null   object\n",
      " 10  Collected_by      5280 non-null   object\n",
      " 11  Other_ID          14382 non-null  object\n",
      " 12  Date              33718 non-null  object\n",
      " 13  Dataset           40405 non-null  object\n",
      " 14  Store             39485 non-null  object\n",
      " 15  Brood             14942 non-null  object\n",
      " 16  Death_Date        318 non-null    object\n",
      " 17  Cross_Type        5133 non-null   object\n",
      " 18  Stage             15 non-null     object\n",
      " 19  Sex               36243 non-null  object\n",
      " 20  Unit_Type         33890 non-null  object\n",
      " 21  file_type         49359 non-null  object\n",
      "dtypes: int64(1), object(21)\n",
      "memory usage: 8.7+ MB\n"
     ]
    }
   ],
   "source": [
    "df_img[\"file_type\"] = df_img[\"Image_name\"].apply(get_file_type)\n",
    "df_img.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_img.to_csv(\"../Jiggins_Zenodo_Img_Master.csv\", index = False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Remaining Question is just if the raw images are duplicated as jpgs or are unique. The `CAMID`'s correspond to samples (as noted in the [zenodo records](https://zenodo.org/record/4289223)), so we can check a single view for this."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "View\n",
       "dorsal                15128\n",
       "ventral               13424\n",
       "Dorsal                 8360\n",
       "Ventral                8090\n",
       "ventral                1644\n",
       "forewing dorsal         406\n",
       "hindwing dorsal         406\n",
       "forewing ventral        406\n",
       "hindwing ventral        406\n",
       "Dorsal and Ventral       18\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_img.View.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['dorsal',\n",
       " 'Dorsal',\n",
       " 'Dorsal and Ventral',\n",
       " 'forewing dorsal',\n",
       " 'hindwing dorsal']"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dorsal_labels = [view for view in list(df_img.View.dropna().unique()) if \"dorsal\" in view.lower()]\n",
    "dorsal_labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 24318 entries, 433 to 49790\n",
      "Data columns (total 22 columns):\n",
      " #   Column            Non-Null Count  Dtype \n",
      "---  ------            --------------  ----- \n",
      " 0   CAMID             24318 non-null  object\n",
      " 1   X                 24318 non-null  int64 \n",
      " 2   Image_name        24318 non-null  object\n",
      " 3   View              24318 non-null  object\n",
      " 4   zenodo_name       24318 non-null  object\n",
      " 5   zenodo_link       24318 non-null  object\n",
      " 6   Sequence          23851 non-null  object\n",
      " 7   Taxonomic_Name    22511 non-null  object\n",
      " 8   Locality          16773 non-null  object\n",
      " 9   Sample_accession  2953 non-null   object\n",
      " 10  Collected_by      2656 non-null   object\n",
      " 11  Other_ID          6931 non-null   object\n",
      " 12  Date              16847 non-null  object\n",
      " 13  Dataset           19935 non-null  object\n",
      " 14  Store             19894 non-null  object\n",
      " 15  Brood             7264 non-null   object\n",
      " 16  Death_Date        107 non-null    object\n",
      " 17  Cross_Type        2572 non-null   object\n",
      " 18  Stage             8 non-null      object\n",
      " 19  Sex               17875 non-null  object\n",
      " 20  Unit_Type         16693 non-null  object\n",
      " 21  file_type         24318 non-null  object\n",
      "dtypes: int64(1), object(21)\n",
      "memory usage: 4.3+ MB\n"
     ]
    }
   ],
   "source": [
    "df_img_dorsal = df_img.loc[df_img[\"View\"].isin(dorsal_labels)]\n",
    "df_img_dorsal.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID               12296\n",
       "X                   24318\n",
       "Image_name          18539\n",
       "View                    5\n",
       "zenodo_name            36\n",
       "zenodo_link            32\n",
       "Sequence            11107\n",
       "Taxonomic_Name        359\n",
       "Locality              642\n",
       "Sample_accession     1564\n",
       "Collected_by           12\n",
       "Other_ID             2897\n",
       "Date                  794\n",
       "Dataset                 8\n",
       "Store                 142\n",
       "Brood                 217\n",
       "Death_Date             64\n",
       "Cross_Type             30\n",
       "Stage                   1\n",
       "Sex                     3\n",
       "Unit_Type               6\n",
       "file_type               3\n",
       "dtype: int64"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_img_dorsal.nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We still have repeated `CAMID`s."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/4002726096.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",
      "  df_img_dorsal[\"CAM_Dupe\"] = df_img_dorsal.duplicated(subset = \"CAMID\", keep = False)\n"
     ]
    }
   ],
   "source": [
    "df_img_dorsal[\"CAM_Dupe\"] = df_img_dorsal.duplicated(subset = \"CAMID\", keep = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAM_Dupe\n",
       "True     20765\n",
       "False     3553\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_img_dorsal[\"CAM_Dupe\"].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 20765 entries, 709 to 49692\n",
      "Data columns (total 23 columns):\n",
      " #   Column            Non-Null Count  Dtype \n",
      "---  ------            --------------  ----- \n",
      " 0   CAMID             20765 non-null  object\n",
      " 1   X                 20765 non-null  int64 \n",
      " 2   Image_name        20765 non-null  object\n",
      " 3   View              20765 non-null  object\n",
      " 4   zenodo_name       20765 non-null  object\n",
      " 5   zenodo_link       20765 non-null  object\n",
      " 6   Sequence          20299 non-null  object\n",
      " 7   Taxonomic_Name    19368 non-null  object\n",
      " 8   Locality          15301 non-null  object\n",
      " 9   Sample_accession  2657 non-null   object\n",
      " 10  Collected_by      2653 non-null   object\n",
      " 11  Other_ID          6107 non-null   object\n",
      " 12  Date              15980 non-null  object\n",
      " 13  Dataset           16862 non-null  object\n",
      " 14  Store             17579 non-null  object\n",
      " 15  Brood             5414 non-null   object\n",
      " 16  Death_Date        26 non-null     object\n",
      " 17  Cross_Type        2572 non-null   object\n",
      " 18  Stage             0 non-null      object\n",
      " 19  Sex               14897 non-null  object\n",
      " 20  Unit_Type         13814 non-null  object\n",
      " 21  file_type         20765 non-null  object\n",
      " 22  CAM_Dupe          20765 non-null  bool  \n",
      "dtypes: bool(1), int64(1), object(21)\n",
      "memory usage: 3.7+ MB\n"
     ]
    }
   ],
   "source": [
    "duplicate_samples = df_img_dorsal.loc[df_img_dorsal[\"CAM_Dupe\"]]\n",
    "duplicate_samples.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID                8743\n",
       "X                   20765\n",
       "Image_name          14986\n",
       "View                    5\n",
       "zenodo_name            32\n",
       "zenodo_link            31\n",
       "Sequence             8407\n",
       "Taxonomic_Name        328\n",
       "Locality              516\n",
       "Sample_accession     1268\n",
       "Collected_by           12\n",
       "Other_ID             2073\n",
       "Date                  578\n",
       "Dataset                 4\n",
       "Store                 130\n",
       "Brood                 144\n",
       "Death_Date             12\n",
       "Cross_Type             30\n",
       "Stage                   0\n",
       "Sex                     3\n",
       "Unit_Type               3\n",
       "file_type               3\n",
       "CAM_Dupe                1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_samples.nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "All sources are impacted."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "file_type\n",
       "jpg    14788\n",
       "raw     5956\n",
       "tif       21\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_samples.file_type.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We will get some added duplication from `forewing dorsal` and `hindwing dorsal`, so we should filter those down to just one for a more accurate assessment."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True     680\n",
       "False    132\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_samples.loc[duplicate_samples[\"View\"].isin([\"forewing dorsal\", \"hindwing dorsal\"])].duplicated(\"CAMID\", keep = \"first\").value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID               132\n",
       "X                   812\n",
       "Image_name          528\n",
       "View                  2\n",
       "zenodo_name           3\n",
       "zenodo_link           3\n",
       "Sequence            132\n",
       "Taxonomic_Name        7\n",
       "Locality             59\n",
       "Sample_accession      0\n",
       "Collected_by          0\n",
       "Other_ID            127\n",
       "Date                 16\n",
       "Dataset               1\n",
       "Store                17\n",
       "Brood                 0\n",
       "Death_Date            0\n",
       "Cross_Type            0\n",
       "Stage                 0\n",
       "Sex                   0\n",
       "Unit_Type             0\n",
       "file_type             2\n",
       "CAM_Dupe              1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_samples.loc[duplicate_samples[\"View\"].isin([\"forewing dorsal\", \"hindwing dorsal\"])].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is only a couple zenodo links, so it is not contributing to the duplication across sources. It also covers two file types."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 3553 entries, 433 to 49790\n",
      "Data columns (total 23 columns):\n",
      " #   Column            Non-Null Count  Dtype \n",
      "---  ------            --------------  ----- \n",
      " 0   CAMID             3553 non-null   object\n",
      " 1   X                 3553 non-null   int64 \n",
      " 2   Image_name        3553 non-null   object\n",
      " 3   View              3553 non-null   object\n",
      " 4   zenodo_name       3553 non-null   object\n",
      " 5   zenodo_link       3553 non-null   object\n",
      " 6   Sequence          3552 non-null   object\n",
      " 7   Taxonomic_Name    3143 non-null   object\n",
      " 8   Locality          1472 non-null   object\n",
      " 9   Sample_accession  296 non-null    object\n",
      " 10  Collected_by      3 non-null      object\n",
      " 11  Other_ID          824 non-null    object\n",
      " 12  Date              867 non-null    object\n",
      " 13  Dataset           3073 non-null   object\n",
      " 14  Store             2315 non-null   object\n",
      " 15  Brood             1850 non-null   object\n",
      " 16  Death_Date        81 non-null     object\n",
      " 17  Cross_Type        0 non-null      object\n",
      " 18  Stage             8 non-null      object\n",
      " 19  Sex               2978 non-null   object\n",
      " 20  Unit_Type         2879 non-null   object\n",
      " 21  file_type         3553 non-null   object\n",
      " 22  CAM_Dupe          3553 non-null   bool  \n",
      "dtypes: bool(1), int64(1), object(21)\n",
      "memory usage: 641.9+ KB\n"
     ]
    }
   ],
   "source": [
    "unique_samples = df_img_dorsal.loc[~df_img_dorsal[\"CAM_Dupe\"]]\n",
    "unique_samples.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CAMID               3553\n",
       "X                   3553\n",
       "Image_name          3553\n",
       "View                   3\n",
       "zenodo_name           21\n",
       "zenodo_link           18\n",
       "Sequence            3016\n",
       "Taxonomic_Name       109\n",
       "Locality             160\n",
       "Sample_accession     296\n",
       "Collected_by           3\n",
       "Other_ID             824\n",
       "Date                 265\n",
       "Dataset                8\n",
       "Store                 76\n",
       "Brood                 95\n",
       "Death_Date            52\n",
       "Cross_Type             0\n",
       "Stage                  1\n",
       "Sex                    3\n",
       "Unit_Type              6\n",
       "file_type              2\n",
       "CAM_Dupe               1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "unique_samples.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "file_type\n",
       "jpg    3535\n",
       "tif      18\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "unique_samples.file_type.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Ah, well all raw images are indeed duplicated. Let's check if they're duplicated among themselves or duplicated to other file types (eg., jpg)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5753, 23)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "4944"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"file_type\"] == \"raw\")].shape)\n",
    "duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"file_type\"] == \"raw\"), \"CAMID\"].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Okay, so there are multiple raw images of the same sample. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "View\n",
       "dorsal             4219\n",
       "Dorsal             1331\n",
       "forewing dorsal     203\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_raw = duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"file_type\"] == \"raw\")]\n",
    "duplicate_raw.View.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "raw_dupe\n",
      "False    4240\n",
      "True     1513\n",
      "Name: count, dtype: int64\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/3049709573.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",
      "  duplicate_raw[\"raw_dupe\"] = duplicate_raw.duplicated(\"CAMID\", keep = False)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "View\n",
       "dorsal             1159\n",
       "Dorsal              212\n",
       "forewing dorsal     142\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_raw[\"raw_dupe\"] = duplicate_raw.duplicated(\"CAMID\", keep = False)\n",
    "print(duplicate_raw[\"raw_dupe\"].value_counts())\n",
    "print()\n",
    "duplicate_raw.loc[duplicate_raw[\"raw_dupe\"], \"View\"].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There does not seem to be an easy method of filtering these other than just keeping the first instance of a particular `CAMID`.\n",
    "\n",
    "It is interesting that non of the Cross Types are unique. Is that just because we have the forewing/hindwing duplication?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2572, 23)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "820"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"Cross_Type\"].notna())].shape)\n",
    "duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"Cross_Type\"].notna()), \"CAMID\"].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There still seem to be 3 images for each specimen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cross_dupe\n",
      "True    2572\n",
      "Name: count, dtype: int64\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_66533/2419376272.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",
      "  duplicate_cross[\"cross_dupe\"] = duplicate_cross.duplicated(\"CAMID\", keep = False)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "View\n",
       "dorsal    2322\n",
       "Dorsal     250\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_cross = duplicate_samples.loc[(duplicate_samples[\"View\"] != \"hindwing dorsal\") & (duplicate_samples[\"Cross_Type\"].notna())]\n",
    "duplicate_cross[\"cross_dupe\"] = duplicate_cross.duplicated(\"CAMID\", keep = False)\n",
    "print(duplicate_cross[\"cross_dupe\"].value_counts())\n",
    "print()\n",
    "duplicate_cross.View.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Yes, they are all duplicated."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "file_type\n",
       "jpg    1753\n",
       "raw     819\n",
       "Name: count, dtype: int64"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "duplicate_cross.file_type.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It seems there's one raw image for each sample (other than one) and then everything else is jpg. I wonder if this includes the `JPG(1)` values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "count = 0\n",
    "for img_name in list(duplicate_cross.Image_name.unique()):\n",
    "    if \"JPG(1)\" in img_name:\n",
    "        count = count + 1\n",
    "count"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "No, that's not the issue."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "count = 0\n",
    "for img_name in list(duplicate_samples.Image_name.unique()):\n",
    "    if \"JPG(1)\" in img_name:\n",
    "        count = count + 1\n",
    "count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "count = 0\n",
    "for img_name in list(df_img_dorsal.Image_name.unique()):\n",
    "    if \"JPG(1)\" in img_name:\n",
    "        count = count + 1\n",
    "count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "count = 0\n",
    "for img_name in list(df_img.Image_name.unique()):\n",
    "    if \"JPG(1)\" in img_name:\n",
    "        count = count + 1\n",
    "count"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There's only one instance of this, and it's not a dorsal image, so that's not part of the issue."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's save all the dorsal images as another CSV (with the duplicate `CAMID` indicator)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_img_dorsal.to_csv(\"../Jiggins_Zenodo_dorsal_Img_Master.csv\", index = False)"
   ]
  },
  {
   "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"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}