Datasets:
File size: 60,990 Bytes
328796a cbd6949 328796a cbd6949 328796a cbd6949 328796a |
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 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 5683 entries, 0 to 5682\n",
"Data columns (total 4 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 coreid 5683 non-null object \n",
" 1 type 0 non-null float64\n",
" 2 identifier 5683 non-null object \n",
" 3 license 0 non-null float64\n",
"dtypes: float64(2), object(2)\n",
"memory usage: 177.7+ KB\n"
]
}
],
"source": [
"multimedia = pd.read_csv(\"../metadata/deduplication/Zenodo_meta_files/multimedia__(rec_3477891).csv\", low_memory=False)\n",
"multimedia.info(show_counts=True)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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>coreid</th>\n",
" <th>type</th>\n",
" <th>identifier</th>\n",
" <th>license</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333/files/CAM041...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>7be80267-dbe9-4f4b-8f73-c7355447d5e1</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2686762/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>b97011cb-c4fd-4ea9-8828-dc920c7b900a</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>6375bf74-3333-4cb6-a0dc-f95c3794edae</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333/files/CAM040...</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" coreid type \\\n",
"0 275ad2e7-bc7e-4e74-832e-869825f5bf0b NaN \n",
"1 cf02ac3a-6204-417c-b342-6f84eab48931 NaN \n",
"2 7be80267-dbe9-4f4b-8f73-c7355447d5e1 NaN \n",
"3 b97011cb-c4fd-4ea9-8828-dc920c7b900a NaN \n",
"4 6375bf74-3333-4cb6-a0dc-f95c3794edae NaN \n",
"\n",
" identifier license \n",
"0 https://zenodo.org/record/2684906/files/CAM008... NaN \n",
"1 https://zenodo.org/record/2714333/files/CAM041... NaN \n",
"2 https://zenodo.org/record/2686762/files/CAM008... NaN \n",
"3 https://zenodo.org/record/2684906/files/CAM008... NaN \n",
"4 https://zenodo.org/record/2714333/files/CAM040... NaN "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multimedia.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'https://zenodo.org/record/2684906/files/CAM008538_d.JPG'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multimedia.identifier[0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's get a filename and record number recorded. Would like to add a `zenodo_link` column to see how that matches up to the master file as well. David said these were mostly resolution for records from [3477891](https://zenodo.org/records/3477891) (where these files are from) at download.\n",
"\n",
"`identifier` is non-null for all entries, but there is one non-Zenodo link."
]
},
{
"cell_type": "code",
"execution_count": 5,
"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>coreid</th>\n",
" <th>type</th>\n",
" <th>identifier</th>\n",
" <th>license</th>\n",
" <th>zenodo_link</th>\n",
" <th>Image_name</th>\n",
" <th>record_number</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906</td>\n",
" <td>CAM008538_d.JPG</td>\n",
" <td>2684906</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333/files/CAM041...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333</td>\n",
" <td>CAM041048_v.JPG</td>\n",
" <td>2714333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>7be80267-dbe9-4f4b-8f73-c7355447d5e1</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2686762/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2686762</td>\n",
" <td>CAM008842_d.JPG</td>\n",
" <td>2686762</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>b97011cb-c4fd-4ea9-8828-dc920c7b900a</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906</td>\n",
" <td>CAM008539_v.JPG</td>\n",
" <td>2684906</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>6375bf74-3333-4cb6-a0dc-f95c3794edae</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333/files/CAM040...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333</td>\n",
" <td>CAM040771_v.JPG</td>\n",
" <td>2714333</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" coreid type \\\n",
"0 275ad2e7-bc7e-4e74-832e-869825f5bf0b NaN \n",
"1 cf02ac3a-6204-417c-b342-6f84eab48931 NaN \n",
"2 7be80267-dbe9-4f4b-8f73-c7355447d5e1 NaN \n",
"3 b97011cb-c4fd-4ea9-8828-dc920c7b900a NaN \n",
"4 6375bf74-3333-4cb6-a0dc-f95c3794edae NaN \n",
"\n",
" identifier license \\\n",
"0 https://zenodo.org/record/2684906/files/CAM008... NaN \n",
"1 https://zenodo.org/record/2714333/files/CAM041... NaN \n",
"2 https://zenodo.org/record/2686762/files/CAM008... NaN \n",
"3 https://zenodo.org/record/2684906/files/CAM008... NaN \n",
"4 https://zenodo.org/record/2714333/files/CAM040... NaN \n",
"\n",
" zenodo_link Image_name record_number \n",
"0 https://zenodo.org/record/2684906 CAM008538_d.JPG 2684906 \n",
"1 https://zenodo.org/record/2714333 CAM041048_v.JPG 2714333 \n",
"2 https://zenodo.org/record/2686762 CAM008842_d.JPG 2686762 \n",
"3 https://zenodo.org/record/2684906 CAM008539_v.JPG 2684906 \n",
"4 https://zenodo.org/record/2714333 CAM040771_v.JPG 2714333 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def get_link_filename(identifier):\n",
" if \"zenodo\" not in identifier:\n",
" link_list = identifier.split(\"com/\")\n",
" link_list[0] = np.nan\n",
" else:\n",
" link_list = identifier.split(\"/files/\")\n",
" # link is first part, filename at end\n",
" return pd.Series(link_list)\n",
"\n",
"def get_record_number(zenodo_link):\n",
" if type(zenodo_link) != float:\n",
" link = zenodo_link.split(\"record/\")\n",
" return link[1]\n",
"\n",
"multimedia[[\"zenodo_link\", \"Image_name\"]] = multimedia[\"identifier\"].apply(get_link_filename)\n",
"multimedia[\"record_number\"] = multimedia[\"zenodo_link\"].apply(get_record_number)\n",
"multimedia.head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"http://earthcape-heliconius.s3-eu-west-1.amazonaws.com/F1FD2804C9E643798A7C1B0D9FBDE4AB.JPG\n"
]
}
],
"source": [
"for link in list(multimedia.identifier):\n",
" if \"zenodo\" not in link:\n",
" print(link)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So there is one image that does not have a Zenodo link."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 5683 entries, 0 to 5682\n",
"Data columns (total 7 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 coreid 5683 non-null object \n",
" 1 type 0 non-null float64\n",
" 2 identifier 5683 non-null object \n",
" 3 license 0 non-null float64\n",
" 4 zenodo_link 5682 non-null object \n",
" 5 Image_name 5683 non-null object \n",
" 6 record_number 5682 non-null object \n",
"dtypes: float64(2), object(5)\n",
"memory usage: 310.9+ KB\n"
]
}
],
"source": [
"multimedia.info()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"coreid 2794\n",
"type 0\n",
"identifier 5683\n",
"license 0\n",
"zenodo_link 12\n",
"Image_name 5683\n",
"record_number 12\n",
"dtype: int64"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multimedia.nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `coreid` is repeated, but the `Image_name` is unique across entries, so this could (hopefully) connect us to the source images."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"record_number\n",
"2707828 1276\n",
"2714333 1113\n",
"2686762 986\n",
"2684906 863\n",
"2677821 703\n",
"2702457 276\n",
"2682458 158\n",
"2682669 124\n",
"2552371 91\n",
"2550097 50\n",
"2553977 22\n",
"2813153 20\n",
"Name: count, dtype: int64"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multimedia.record_number.value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Interesting, it would seem that record 3477891 is a collection of these 12 other records. It matches with this [GBIF Collection](https://www.gbif.org/dataset/34f8683a-dfc0-46b8-acf6-390fe5ca6b92) that is the \"collection records from the research group of Chris Jiggins at the University of Cambridge derived from almost 20 years of field studies. Many records include images as well as locality data.\" released in October 2019."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 4372 entries, 0 to 4371\n",
"Data columns (total 29 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 id 4372 non-null object \n",
" 1 occurrenceID 4372 non-null object \n",
" 2 catalogNumber 4372 non-null object \n",
" 3 datasetName 4372 non-null object \n",
" 4 recordNumber 0 non-null float64\n",
" 5 otherCatalogNumbers 33 non-null object \n",
" 6 basisOfRecord 4372 non-null object \n",
" 7 eventDate 3806 non-null object \n",
" 8 locality 4372 non-null object \n",
" 9 country 4372 non-null object \n",
" 10 decimalLatitude 4372 non-null float64\n",
" 11 decimalLongitude 4372 non-null float64\n",
" 12 geodeticDatum 4372 non-null int64 \n",
" 13 year 3806 non-null float64\n",
" 14 sex 3882 non-null object \n",
" 15 lifeStage 39 non-null object \n",
" 16 recordedBy 0 non-null float64\n",
" 17 individualCount 4372 non-null int64 \n",
" 18 taxonId 1105 non-null float64\n",
" 19 scientificName 4360 non-null object \n",
" 20 scientificNameAuthorship 0 non-null float64\n",
" 21 taxonRank 4358 non-null object \n",
" 22 genus 4358 non-null object \n",
" 23 family 4086 non-null object \n",
" 24 order 4086 non-null object \n",
" 25 class 4086 non-null object \n",
" 26 kingdom 4086 non-null object \n",
" 27 coordinateUncertaintyInMeters 0 non-null float64\n",
" 28 dynamicProperties 4372 non-null object \n",
"dtypes: float64(8), int64(2), object(19)\n",
"memory usage: 990.7+ KB\n"
]
}
],
"source": [
"occurrence = pd.read_csv(\"../metadata/deduplication/Zenodo_meta_files/occurrences__(rec_3477891).csv\",low_memory=False)\n",
"occurrence.info(show_counts=True)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"id 4372\n",
"occurrenceID 4372\n",
"catalogNumber 4372\n",
"datasetName 1\n",
"dtype: int64"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"occurrence[(occurrence.columns)[:4]].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Are `id` and `occurrenceID` all equal?"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(4372, 29)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"occurrence.loc[occurrence[\"id\"] == occurrence[\"occurrenceID\"]].shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This has a record number column, but there are no non-null values, so we'll try to fill that in. Except there is nothing to use to fill it in...we have to connect on `catalogNumber` to the `id` to the `coreid`, but `catalogNumber` is just the CAMID and we have more unique IDs than there are in the multimedia file..."
]
},
{
"cell_type": "code",
"execution_count": 13,
"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>id</th>\n",
" <th>occurrenceID</th>\n",
" <th>catalogNumber</th>\n",
" <th>datasetName</th>\n",
" <th>recordNumber</th>\n",
" <th>otherCatalogNumbers</th>\n",
" <th>basisOfRecord</th>\n",
" <th>eventDate</th>\n",
" <th>locality</th>\n",
" <th>country</th>\n",
" <th>...</th>\n",
" <th>scientificName</th>\n",
" <th>scientificNameAuthorship</th>\n",
" <th>taxonRank</th>\n",
" <th>genus</th>\n",
" <th>family</th>\n",
" <th>order</th>\n",
" <th>class</th>\n",
" <th>kingdom</th>\n",
" <th>coordinateUncertaintyInMeters</th>\n",
" <th>dynamicProperties</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>00075b7f-3920-4987-a3e4-e98568a38558</td>\n",
" <td>00075b7f-3920-4987-a3e4-e98568a38558</td>\n",
" <td>CAM040599</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>PreservedSpecimen</td>\n",
" <td>2017-03-07</td>\n",
" <td>Mashpi to Pachijal 2</td>\n",
" <td>Ecuador</td>\n",
" <td>...</td>\n",
" <td>Heliconius cydno ssp. alithea</td>\n",
" <td>NaN</td>\n",
" <td>Subspecies</td>\n",
" <td>Heliconius</td>\n",
" <td>Nymphalidae</td>\n",
" <td>Lepidoptera</td>\n",
" <td>Insecta</td>\n",
" <td>Animalia</td>\n",
" <td>NaN</td>\n",
" <td>{}</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>000dc8ca-5d60-4aff-9823-33d20d52c7cd</td>\n",
" <td>000dc8ca-5d60-4aff-9823-33d20d52c7cd</td>\n",
" <td>CAM040277</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>PreservedSpecimen</td>\n",
" <td>2017-01-30</td>\n",
" <td>Km 119 Baeza - Lago Agrio</td>\n",
" <td>Ecuador</td>\n",
" <td>...</td>\n",
" <td>Actinote sp.</td>\n",
" <td>NaN</td>\n",
" <td>Species</td>\n",
" <td>Actinote</td>\n",
" <td>Nymphalidae</td>\n",
" <td>Lepidoptera</td>\n",
" <td>Insecta</td>\n",
" <td>Animalia</td>\n",
" <td>NaN</td>\n",
" <td>{}</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>001b4619-bfe3-4a89-9709-45a70c1fa380</td>\n",
" <td>001b4619-bfe3-4a89-9709-45a70c1fa380</td>\n",
" <td>CAM120368</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>PreservedSpecimen</td>\n",
" <td>2005-11-15</td>\n",
" <td>Anangu Boca del Rio ECD OR</td>\n",
" <td>Ecuador</td>\n",
" <td>...</td>\n",
" <td>Pseudoscada timna ssp. utilla</td>\n",
" <td>NaN</td>\n",
" <td>Subspecies</td>\n",
" <td>Pseudoscada</td>\n",
" <td>Nymphalidae</td>\n",
" <td>Lepidoptera</td>\n",
" <td>Insecta</td>\n",
" <td>Animalia</td>\n",
" <td>NaN</td>\n",
" <td>{}</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0021e86f-64b3-4ce8-b872-f783f00f5f6a</td>\n",
" <td>0021e86f-64b3-4ce8-b872-f783f00f5f6a</td>\n",
" <td>CAM014638</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>PreservedSpecimen</td>\n",
" <td>2009-11-23</td>\n",
" <td>Puerta Lara</td>\n",
" <td>Panamá</td>\n",
" <td>...</td>\n",
" <td>Heliconius melpomene ssp. melpomene</td>\n",
" <td>NaN</td>\n",
" <td>Subspecies</td>\n",
" <td>Heliconius</td>\n",
" <td>Nymphalidae</td>\n",
" <td>Lepidoptera</td>\n",
" <td>Insecta</td>\n",
" <td>Animalia</td>\n",
" <td>NaN</td>\n",
" <td>{}</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0034a857-9ed6-45be-b437-8e20eef541bb</td>\n",
" <td>0034a857-9ed6-45be-b437-8e20eef541bb</td>\n",
" <td>CAM008071</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>PreservedSpecimen</td>\n",
" <td>2000-12-17</td>\n",
" <td>Gamboa #183</td>\n",
" <td>Panamá</td>\n",
" <td>...</td>\n",
" <td>Anthanassa drusilla</td>\n",
" <td>NaN</td>\n",
" <td>Species</td>\n",
" <td>Anthanassa</td>\n",
" <td>Nymphalidae</td>\n",
" <td>Lepidoptera</td>\n",
" <td>Insecta</td>\n",
" <td>Animalia</td>\n",
" <td>NaN</td>\n",
" <td>{}</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 29 columns</p>\n",
"</div>"
],
"text/plain": [
" id occurrenceID \\\n",
"0 00075b7f-3920-4987-a3e4-e98568a38558 00075b7f-3920-4987-a3e4-e98568a38558 \n",
"1 000dc8ca-5d60-4aff-9823-33d20d52c7cd 000dc8ca-5d60-4aff-9823-33d20d52c7cd \n",
"2 001b4619-bfe3-4a89-9709-45a70c1fa380 001b4619-bfe3-4a89-9709-45a70c1fa380 \n",
"3 0021e86f-64b3-4ce8-b872-f783f00f5f6a 0021e86f-64b3-4ce8-b872-f783f00f5f6a \n",
"4 0034a857-9ed6-45be-b437-8e20eef541bb 0034a857-9ed6-45be-b437-8e20eef541bb \n",
"\n",
" catalogNumber datasetName \\\n",
"0 CAM040599 Heliconiine Butterfly Collection Records from ... \n",
"1 CAM040277 Heliconiine Butterfly Collection Records from ... \n",
"2 CAM120368 Heliconiine Butterfly Collection Records from ... \n",
"3 CAM014638 Heliconiine Butterfly Collection Records from ... \n",
"4 CAM008071 Heliconiine Butterfly Collection Records from ... \n",
"\n",
" recordNumber otherCatalogNumbers basisOfRecord eventDate \\\n",
"0 NaN NaN PreservedSpecimen 2017-03-07 \n",
"1 NaN NaN PreservedSpecimen 2017-01-30 \n",
"2 NaN NaN PreservedSpecimen 2005-11-15 \n",
"3 NaN NaN PreservedSpecimen 2009-11-23 \n",
"4 NaN NaN PreservedSpecimen 2000-12-17 \n",
"\n",
" locality country ... \\\n",
"0 Mashpi to Pachijal 2 Ecuador ... \n",
"1 Km 119 Baeza - Lago Agrio Ecuador ... \n",
"2 Anangu Boca del Rio ECD OR Ecuador ... \n",
"3 Puerta Lara Panamá ... \n",
"4 Gamboa #183 Panamá ... \n",
"\n",
" scientificName scientificNameAuthorship taxonRank \\\n",
"0 Heliconius cydno ssp. alithea NaN Subspecies \n",
"1 Actinote sp. NaN Species \n",
"2 Pseudoscada timna ssp. utilla NaN Subspecies \n",
"3 Heliconius melpomene ssp. melpomene NaN Subspecies \n",
"4 Anthanassa drusilla NaN Species \n",
"\n",
" genus family order class kingdom \\\n",
"0 Heliconius Nymphalidae Lepidoptera Insecta Animalia \n",
"1 Actinote Nymphalidae Lepidoptera Insecta Animalia \n",
"2 Pseudoscada Nymphalidae Lepidoptera Insecta Animalia \n",
"3 Heliconius Nymphalidae Lepidoptera Insecta Animalia \n",
"4 Anthanassa Nymphalidae Lepidoptera Insecta Animalia \n",
"\n",
" coordinateUncertaintyInMeters dynamicProperties \n",
"0 NaN {} \n",
"1 NaN {} \n",
"2 NaN {} \n",
"3 NaN {} \n",
"4 NaN {} \n",
"\n",
"[5 rows x 29 columns]"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"occurrence.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"How many unique CAMIDs do we have in `multimedia`?"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2802"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def get_camid(image_name):\n",
" if \"_\" in image_name:\n",
" return image_name.split(\"_\")[0]\n",
" else:\n",
" # We have at least one record with image name that doesn't have CAMID (the non-zenodo record)\n",
" return np.nan\n",
"\n",
"multimedia[\"CAMID\"] = multimedia[\"Image_name\"].apply(get_camid)\n",
"multimedia[\"CAMID\"].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Okay, so there are more unique `CAMID`s than there are unique `coreid`s, but less than there are unique CAMIDs (`catalogNumber`) in `occurrence`...\n",
"\n",
"What do I get if I merge these on `CAMID` and `coreid`?"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 5407 entries, 0 to 5406\n",
"Data columns (total 37 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 coreid 5407 non-null object \n",
" 1 type 0 non-null float64\n",
" 2 identifier 5407 non-null object \n",
" 3 license 0 non-null float64\n",
" 4 zenodo_link 5407 non-null object \n",
" 5 Image_name 5407 non-null object \n",
" 6 record_number 5407 non-null object \n",
" 7 CAMID 5407 non-null object \n",
" 8 id 5407 non-null object \n",
" 9 occurrenceID 5407 non-null object \n",
" 10 catalogNumber 5407 non-null object \n",
" 11 datasetName 5407 non-null object \n",
" 12 recordNumber 0 non-null float64\n",
" 13 otherCatalogNumbers 0 non-null object \n",
" 14 basisOfRecord 5407 non-null object \n",
" 15 eventDate 4937 non-null object \n",
" 16 locality 5407 non-null object \n",
" 17 country 5407 non-null object \n",
" 18 decimalLatitude 5407 non-null float64\n",
" 19 decimalLongitude 5407 non-null float64\n",
" 20 geodeticDatum 5407 non-null int64 \n",
" 21 year 4937 non-null float64\n",
" 22 sex 5307 non-null object \n",
" 23 lifeStage 0 non-null object \n",
" 24 recordedBy 0 non-null float64\n",
" 25 individualCount 5407 non-null int64 \n",
" 26 taxonId 1473 non-null float64\n",
" 27 scientificName 5389 non-null object \n",
" 28 scientificNameAuthorship 0 non-null float64\n",
" 29 taxonRank 5387 non-null object \n",
" 30 genus 5387 non-null object \n",
" 31 family 5211 non-null object \n",
" 32 order 5211 non-null object \n",
" 33 class 5211 non-null object \n",
" 34 kingdom 5211 non-null object \n",
" 35 coordinateUncertaintyInMeters 0 non-null float64\n",
" 36 dynamicProperties 5407 non-null object \n",
"dtypes: float64(10), int64(2), object(25)\n",
"memory usage: 1.5+ MB\n"
]
}
],
"source": [
"test_merge = pd.merge(multimedia,\n",
" occurrence,\n",
" left_on = [\"coreid\", \"CAMID\"],\n",
" right_on = [\"id\", \"catalogNumber\"],\n",
" how = \"inner\")\n",
"test_merge.info(show_counts=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So there are about 270 images listed in `multimedia` that are unaccounted for in `occurences`."
]
},
{
"cell_type": "code",
"execution_count": 16,
"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>coreid</th>\n",
" <th>type</th>\n",
" <th>identifier</th>\n",
" <th>license</th>\n",
" <th>zenodo_link</th>\n",
" <th>Image_name</th>\n",
" <th>record_number</th>\n",
" <th>CAMID</th>\n",
" <th>id</th>\n",
" <th>occurrenceID</th>\n",
" <th>catalogNumber</th>\n",
" <th>datasetName</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906</td>\n",
" <td>CAM008538_d.JPG</td>\n",
" <td>2684906</td>\n",
" <td>CAM008538</td>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>CAM008538</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2684906</td>\n",
" <td>CAM008538_v.JPG</td>\n",
" <td>2684906</td>\n",
" <td>CAM008538</td>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>275ad2e7-bc7e-4e74-832e-869825f5bf0b</td>\n",
" <td>CAM008538</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333/files/CAM041...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333</td>\n",
" <td>CAM041048_v.JPG</td>\n",
" <td>2714333</td>\n",
" <td>CAM041048</td>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>CAM041048</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333/files/CAM041...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2714333</td>\n",
" <td>CAM041048_d.JPG</td>\n",
" <td>2714333</td>\n",
" <td>CAM041048</td>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>cf02ac3a-6204-417c-b342-6f84eab48931</td>\n",
" <td>CAM041048</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>7be80267-dbe9-4f4b-8f73-c7355447d5e1</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2686762/files/CAM008...</td>\n",
" <td>NaN</td>\n",
" <td>https://zenodo.org/record/2686762</td>\n",
" <td>CAM008842_d.JPG</td>\n",
" <td>2686762</td>\n",
" <td>CAM008842</td>\n",
" <td>7be80267-dbe9-4f4b-8f73-c7355447d5e1</td>\n",
" <td>7be80267-dbe9-4f4b-8f73-c7355447d5e1</td>\n",
" <td>CAM008842</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" coreid type \\\n",
"0 275ad2e7-bc7e-4e74-832e-869825f5bf0b NaN \n",
"1 275ad2e7-bc7e-4e74-832e-869825f5bf0b NaN \n",
"2 cf02ac3a-6204-417c-b342-6f84eab48931 NaN \n",
"3 cf02ac3a-6204-417c-b342-6f84eab48931 NaN \n",
"4 7be80267-dbe9-4f4b-8f73-c7355447d5e1 NaN \n",
"\n",
" identifier license \\\n",
"0 https://zenodo.org/record/2684906/files/CAM008... NaN \n",
"1 https://zenodo.org/record/2684906/files/CAM008... NaN \n",
"2 https://zenodo.org/record/2714333/files/CAM041... NaN \n",
"3 https://zenodo.org/record/2714333/files/CAM041... NaN \n",
"4 https://zenodo.org/record/2686762/files/CAM008... NaN \n",
"\n",
" zenodo_link Image_name record_number \\\n",
"0 https://zenodo.org/record/2684906 CAM008538_d.JPG 2684906 \n",
"1 https://zenodo.org/record/2684906 CAM008538_v.JPG 2684906 \n",
"2 https://zenodo.org/record/2714333 CAM041048_v.JPG 2714333 \n",
"3 https://zenodo.org/record/2714333 CAM041048_d.JPG 2714333 \n",
"4 https://zenodo.org/record/2686762 CAM008842_d.JPG 2686762 \n",
"\n",
" CAMID id \\\n",
"0 CAM008538 275ad2e7-bc7e-4e74-832e-869825f5bf0b \n",
"1 CAM008538 275ad2e7-bc7e-4e74-832e-869825f5bf0b \n",
"2 CAM041048 cf02ac3a-6204-417c-b342-6f84eab48931 \n",
"3 CAM041048 cf02ac3a-6204-417c-b342-6f84eab48931 \n",
"4 CAM008842 7be80267-dbe9-4f4b-8f73-c7355447d5e1 \n",
"\n",
" occurrenceID catalogNumber \\\n",
"0 275ad2e7-bc7e-4e74-832e-869825f5bf0b CAM008538 \n",
"1 275ad2e7-bc7e-4e74-832e-869825f5bf0b CAM008538 \n",
"2 cf02ac3a-6204-417c-b342-6f84eab48931 CAM041048 \n",
"3 cf02ac3a-6204-417c-b342-6f84eab48931 CAM041048 \n",
"4 7be80267-dbe9-4f4b-8f73-c7355447d5e1 CAM008842 \n",
"\n",
" datasetName \n",
"0 Heliconiine Butterfly Collection Records from ... \n",
"1 Heliconiine Butterfly Collection Records from ... \n",
"2 Heliconiine Butterfly Collection Records from ... \n",
"3 Heliconiine Butterfly Collection Records from ... \n",
"4 Heliconiine Butterfly Collection Records from ... "
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test_merge[list(test_merge.columns)[:12]].head()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"coreid 2713\n",
"CAMID 2713\n",
"identifier 5407\n",
"record_number 10\n",
"dtype: int64"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"test_merge[[\"coreid\", \"CAMID\", \"identifier\", \"record_number\"]].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Uniqueness counts from `multimedia`:\n",
"```\n",
"CAMID 2802\n",
"coreid 2794\n",
"identifier 5683\n",
"Image_name 5683\n",
"record_number 12\n",
"```\n",
"It seems there are 2 records that don't match on IDs, which is a loss of 81 unique listings in `multimedia`.\n",
"\n",
"How will this compare to the entries from record 3477891 in our master file? Also, are these other records in there?"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Index: 5501 entries, 3235 to 42852\n",
"Data columns (total 28 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID 5501 non-null object\n",
" 1 X 5501 non-null int64 \n",
" 2 Image_name 5501 non-null object\n",
" 3 View 5501 non-null object\n",
" 4 zenodo_name 5501 non-null object\n",
" 5 zenodo_link 5501 non-null object\n",
" 6 Sequence 5501 non-null object\n",
" 7 Taxonomic_Name 5501 non-null object\n",
" 8 Locality 5501 non-null object\n",
" 9 Sample_accession 925 non-null object\n",
" 10 Collected_by 0 non-null object\n",
" 11 Other_ID 12 non-null object\n",
" 12 Date 5025 non-null object\n",
" 13 Dataset 5501 non-null object\n",
" 14 Store 5421 non-null object\n",
" 15 Brood 4 non-null object\n",
" 16 Death_Date 0 non-null object\n",
" 17 Cross_Type 0 non-null object\n",
" 18 Stage 0 non-null object\n",
" 19 Sex 5435 non-null object\n",
" 20 Unit_Type 5501 non-null object\n",
" 21 file_type 5501 non-null object\n",
" 22 record_number 5501 non-null int64 \n",
" 23 species 5501 non-null object\n",
" 24 subspecies 3673 non-null object\n",
" 25 genus 5501 non-null object\n",
" 26 file_url 5501 non-null object\n",
" 27 hybrid_stat 3705 non-null object\n",
"dtypes: int64(2), object(26)\n",
"memory usage: 1.2+ MB\n"
]
}
],
"source": [
"df = pd.read_csv(\"../Jiggins_Zenodo_Img_Master.csv\", low_memory = False)\n",
"\n",
"odd_record = df.loc[df[\"record_number\"] == 3477891]\n",
"odd_record.info()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"id_cols = [\"CAMID\", \"X\", \"Image_name\", \"zenodo_name\", \"zenodo_link\", \"file_url\", \"Dataset\"]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 2704\n",
"X 5501\n",
"Image_name 5497\n",
"zenodo_name 1\n",
"zenodo_link 1\n",
"file_url 5497\n",
"Dataset 1\n",
"dtype: int64"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"odd_record[id_cols].nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This falls somewhere between the `multimedia` & `occurrence` merge, and the `multimedia` file. Let's see a sample of these images then try aligning it with `multimedia` on `Image_name`."
]
},
{
"cell_type": "code",
"execution_count": 21,
"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",
" <th>file_url</th>\n",
" <th>Dataset</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3235</th>\n",
" <td>CAM000001</td>\n",
" <td>44387</td>\n",
" <td>CAM000001_v.JPG</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM000...</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3236</th>\n",
" <td>CAM000001</td>\n",
" <td>44386</td>\n",
" <td>CAM000001_d.JPG</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM000...</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3237</th>\n",
" <td>CAM000003</td>\n",
" <td>44388</td>\n",
" <td>CAM000003_d.JPG</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM000...</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3240</th>\n",
" <td>CAM000003</td>\n",
" <td>44389</td>\n",
" <td>CAM000003_v.JPG</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM000...</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3242</th>\n",
" <td>CAM000004</td>\n",
" <td>44390</td>\n",
" <td>CAM000004_d.JPG</td>\n",
" <td>occurences_and_multimedia.csv</td>\n",
" <td>https://zenodo.org/record/3477891</td>\n",
" <td>https://zenodo.org/record/3477891/files/CAM000...</td>\n",
" <td>Heliconiine Butterfly Collection Records from ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" CAMID X Image_name zenodo_name \\\n",
"3235 CAM000001 44387 CAM000001_v.JPG occurences_and_multimedia.csv \n",
"3236 CAM000001 44386 CAM000001_d.JPG occurences_and_multimedia.csv \n",
"3237 CAM000003 44388 CAM000003_d.JPG occurences_and_multimedia.csv \n",
"3240 CAM000003 44389 CAM000003_v.JPG occurences_and_multimedia.csv \n",
"3242 CAM000004 44390 CAM000004_d.JPG occurences_and_multimedia.csv \n",
"\n",
" zenodo_link \\\n",
"3235 https://zenodo.org/record/3477891 \n",
"3236 https://zenodo.org/record/3477891 \n",
"3237 https://zenodo.org/record/3477891 \n",
"3240 https://zenodo.org/record/3477891 \n",
"3242 https://zenodo.org/record/3477891 \n",
"\n",
" file_url \\\n",
"3235 https://zenodo.org/record/3477891/files/CAM000... \n",
"3236 https://zenodo.org/record/3477891/files/CAM000... \n",
"3237 https://zenodo.org/record/3477891/files/CAM000... \n",
"3240 https://zenodo.org/record/3477891/files/CAM000... \n",
"3242 https://zenodo.org/record/3477891/files/CAM000... \n",
"\n",
" Dataset \n",
"3235 Heliconiine Butterfly Collection Records from ... \n",
"3236 Heliconiine Butterfly Collection Records from ... \n",
"3237 Heliconiine Butterfly Collection Records from ... \n",
"3240 Heliconiine Butterfly Collection Records from ... \n",
"3242 Heliconiine Butterfly Collection Records from ... "
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"odd_record[id_cols].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"They are all labeled as that dataset with the `zenodo_name` \"occurrences_and_multimedia.csv\" because it was a combo of these used by Christopher to populate the CSV."
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 5501 entries, 0 to 5500\n",
"Data columns (total 14 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 CAMID_master 5501 non-null object \n",
" 1 X 5501 non-null int64 \n",
" 2 Image_name 5501 non-null object \n",
" 3 zenodo_name 5501 non-null object \n",
" 4 zenodo_link_master 5501 non-null object \n",
" 5 file_url 5501 non-null object \n",
" 6 Dataset 5501 non-null object \n",
" 7 coreid 5501 non-null object \n",
" 8 type 0 non-null float64\n",
" 9 identifier 5501 non-null object \n",
" 10 license 0 non-null float64\n",
" 11 zenodo_link_media 5501 non-null object \n",
" 12 record_number 5501 non-null object \n",
" 13 CAMID_media 5409 non-null object \n",
"dtypes: float64(2), int64(1), object(11)\n",
"memory usage: 601.8+ KB\n"
]
}
],
"source": [
"odd_multimedia = pd.merge(odd_record[id_cols],\n",
" multimedia,\n",
" on = \"Image_name\",\n",
" how = \"inner\",\n",
" suffixes = (\"_master\", \"_media\"))\n",
"odd_multimedia.info()"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID_master 2704\n",
"X 5501\n",
"Image_name 5497\n",
"zenodo_name 1\n",
"zenodo_link_master 1\n",
"file_url 5497\n",
"Dataset 1\n",
"coreid 2704\n",
"type 0\n",
"identifier 5497\n",
"license 0\n",
"zenodo_link_media 12\n",
"record_number 12\n",
"CAMID_media 2712\n",
"dtype: int64"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"odd_multimedia.nunique()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Looks like all the images were captured (there are more entries than unique `Image_name` & URL), so we should be able to replace the URLs in the master file with the multimedia image URLs directly.\n",
"\n",
"We do want to compare record numbers to the master file first."
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"media_records = list(multimedia.record_number.unique())\n",
"media_imgs = list(multimedia.Image_name.unique())\n",
"master_records = list(df.record_number.unique())\n",
"\n",
"overlap_records = [record for record in media_records if record in master_records]\n",
"len(overlap_records)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ahhh no duplication then. Interesting (and good!)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(5501, 55)"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"non_odd_df = df.loc[df[\"record_number\"] != 3477891]\n",
"\n",
"test_odd_merge = pd.merge(odd_record,\n",
" non_odd_df,\n",
" on = \"Image_name\",\n",
" how = \"inner\")\n",
"test_odd_merge.shape"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'https://zenodo.org/record/2677821/files/CAM000003_v.JPG'"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multimedia.loc[multimedia[\"Image_name\"] == \"CAM000003_v.JPG\", \"identifier\"].values[0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Duplication in `Image_name`, though that's not necessarily unexpected."
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 2704\n",
"X 5501\n",
"Image_name 5497\n",
"View 2\n",
"zenodo_name 1\n",
"zenodo_link 1\n",
"Sequence 2704\n",
"Taxonomic_Name 195\n",
"Locality 205\n",
"Sample_accession 446\n",
"Collected_by 0\n",
"Other_ID 5\n",
"Date 200\n",
"Dataset 1\n",
"Store 55\n",
"Brood 2\n",
"Death_Date 0\n",
"Cross_Type 0\n",
"Stage 0\n",
"Sex 3\n",
"Unit_Type 2\n",
"file_type 1\n",
"record_number 1\n",
"species 121\n",
"subspecies 93\n",
"genus 38\n",
"file_url 5497\n",
"hybrid_stat 2\n",
"dtype: int64"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"for image_name in list(odd_record.Image_name.unique()):\n",
" url = multimedia.loc[multimedia[\"Image_name\"] == image_name, \"identifier\"].values[0]\n",
" df.loc[(df[\"record_number\"] == 3477891) & (df[\"Image_name\"] == image_name), \"file_url\"] = url\n",
"\n",
"df.loc[df[\"record_number\"] == 3477891].nunique()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 11991\n",
"X 44809\n",
"Image_name 36281\n",
"zenodo_name 33\n",
"zenodo_link 30\n",
"file_url 39297\n",
"Dataset 8\n",
"dtype: int64"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[id_cols].nunique()"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Dataset\n",
"Heliconiine Butterfly Collection Records from University of Cambridge 25211\n",
"Patricio Salazar 7519\n",
"Nadeau Sheffield 3233\n",
"Bogota Collection (Camilo Salazar) 982\n",
"Cambridge Collection 47\n",
"Mallet 22\n",
"Merril_Gamboa 6\n",
"STRI Collection (Owen) 4\n",
"Name: count, dtype: int64"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.Dataset.value_counts()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CAMID 6538\n",
"X 25211\n",
"Image_name 17362\n",
"View 7\n",
"zenodo_name 17\n",
"zenodo_link 17\n",
"Sequence 6538\n",
"Taxonomic_Name 287\n",
"Locality 372\n",
"Sample_accession 485\n",
"Collected_by 0\n",
"Other_ID 1123\n",
"Date 282\n",
"Dataset 1\n",
"Store 102\n",
"Brood 102\n",
"Death_Date 0\n",
"Cross_Type 0\n",
"Stage 0\n",
"Sex 3\n",
"Unit_Type 2\n",
"file_type 2\n",
"record_number 17\n",
"species 207\n",
"subspecies 99\n",
"genus 82\n",
"file_url 19710\n",
"hybrid_stat 2\n",
"dtype: int64"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"HBCRUC = \"Heliconiine Butterfly Collection Records from University of Cambridge\"\n",
"df.loc[df.Dataset == HBCRUC].nunique()"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"df.to_csv(\"../metadata/Jiggins_Zenodo_Img_Master_3477891Patch.csv\", index = False)"
]
}
],
"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
}
|