Sanity check on catalog to cargo archive match
Browse filesEverything in the catalog matches to the cargo archive.
The combined manifests can't pull in all the images from that merge (this is where the missing images come in).
.gitattributes
CHANGED
|
@@ -68,3 +68,5 @@ eol_realign/data/links_manifest_cargo_on_md5.csv filter=lfs diff=lfs merge=lfs -
|
|
| 68 |
eol_realign/data/links_cargo_manifest_IDmismatch.csv filter=lfs diff=lfs merge=lfs -text
|
| 69 |
eol_realign/data/eol-cargo-archive_combined-manifest-checksums_links.csv filter=lfs diff=lfs merge=lfs -text
|
| 70 |
eol_realign/data/eol-cargo-archive_catalog_combined-manifest-checksums_links.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 68 |
eol_realign/data/links_cargo_manifest_IDmismatch.csv filter=lfs diff=lfs merge=lfs -text
|
| 69 |
eol_realign/data/eol-cargo-archive_combined-manifest-checksums_links.csv filter=lfs diff=lfs merge=lfs -text
|
| 70 |
eol_realign/data/eol-cargo-archive_catalog_combined-manifest-checksums_links.csv filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
eol_realign/data/checksums_media_cargo_archive.csv filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
eol_realign/data/combined_manifest_with_checksums.csv filter=lfs diff=lfs merge=lfs -text
|
eol_realign/data/checksums_media_cargo_archive.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f5b30008ba49fd342881e7ecd47c248d2a1c9b39960913518fcb78896bef3805
|
| 3 |
+
size 490626452
|
eol_realign/data/combined_manifest_with_checksums.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:03c75970541ad805c8f308dbe19d5b71642b724ced6324b240db41cd3e37b045
|
| 3 |
+
size 4655278768
|
eol_realign/notebooks/catalog-cargo-manifest_test.ipynb
AD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 5 |
+
"execution_count": 1,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"import pandas as pd"
|
| 10 |
+
]
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"cell_type": "code",
|
| 14 |
+
"execution_count": 2,
|
| 15 |
+
"metadata": {},
|
| 16 |
+
"outputs": [],
|
| 17 |
+
"source": [
|
| 18 |
+
"TOL_FILEPATH = \"../../data/\""
|
| 19 |
+
]
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"cell_type": "code",
|
| 23 |
+
"execution_count": 3,
|
| 24 |
+
"metadata": {},
|
| 25 |
+
"outputs": [],
|
| 26 |
+
"source": [
|
| 27 |
+
"tol = pd.read_csv(TOL_FILEPATH + \"catalog.csv\", low_memory=False)"
|
| 28 |
+
]
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"cell_type": "code",
|
| 32 |
+
"execution_count": 4,
|
| 33 |
+
"metadata": {},
|
| 34 |
+
"outputs": [
|
| 35 |
+
{
|
| 36 |
+
"name": "stdout",
|
| 37 |
+
"output_type": "stream",
|
| 38 |
+
"text": [
|
| 39 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 40 |
+
"Index: 6250420 entries, 956715 to 11000930\n",
|
| 41 |
+
"Data columns (total 12 columns):\n",
|
| 42 |
+
" # Column Non-Null Count Dtype \n",
|
| 43 |
+
"--- ------ -------------- ----- \n",
|
| 44 |
+
" 0 split 6250420 non-null object\n",
|
| 45 |
+
" 1 treeoflife_id 6250420 non-null object\n",
|
| 46 |
+
" 2 eol_content_id 6250420 non-null int64 \n",
|
| 47 |
+
" 3 eol_page_id 6250420 non-null int64 \n",
|
| 48 |
+
" 4 kingdom 5989611 non-null object\n",
|
| 49 |
+
" 5 phylum 5991207 non-null object\n",
|
| 50 |
+
" 6 class 5971438 non-null object\n",
|
| 51 |
+
" 7 order 5965299 non-null object\n",
|
| 52 |
+
" 8 family 5948728 non-null object\n",
|
| 53 |
+
" 9 genus 5940313 non-null object\n",
|
| 54 |
+
" 10 species 5951613 non-null object\n",
|
| 55 |
+
" 11 common 6250420 non-null object\n",
|
| 56 |
+
"dtypes: int64(2), object(10)\n",
|
| 57 |
+
"memory usage: 619.9+ MB\n"
|
| 58 |
+
]
|
| 59 |
+
}
|
| 60 |
+
],
|
| 61 |
+
"source": [
|
| 62 |
+
"# Remove duplicates\n",
|
| 63 |
+
"tol = tol.loc[tol.split != 'train_small']\n",
|
| 64 |
+
"\n",
|
| 65 |
+
"# Reduce to just EOL data & columns\n",
|
| 66 |
+
"eol = tol.loc[tol[\"eol_content_id\"].notna()]\n",
|
| 67 |
+
"eol_cols = [col for col in list(eol.columns) if \"bioscan\" not in col and \"inat\" not in col]\n",
|
| 68 |
+
"eol_catalog = eol[eol_cols]\n",
|
| 69 |
+
"\n",
|
| 70 |
+
"# Cast EOL content & page IDs as ints\n",
|
| 71 |
+
"eol_catalog = eol_catalog.astype({\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"})\n",
|
| 72 |
+
"eol_catalog.info(show_counts = True)"
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"cell_type": "code",
|
| 77 |
+
"execution_count": 5,
|
| 78 |
+
"metadata": {},
|
| 79 |
+
"outputs": [],
|
| 80 |
+
"source": [
|
| 81 |
+
"archive = pd.read_csv(\"../data/checksums_media_cargo_archive.csv\", low_memory=False)"
|
| 82 |
+
]
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"cell_type": "code",
|
| 86 |
+
"execution_count": 6,
|
| 87 |
+
"metadata": {},
|
| 88 |
+
"outputs": [
|
| 89 |
+
{
|
| 90 |
+
"data": {
|
| 91 |
+
"text/html": [
|
| 92 |
+
"<div>\n",
|
| 93 |
+
"<style scoped>\n",
|
| 94 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 95 |
+
" vertical-align: middle;\n",
|
| 96 |
+
" }\n",
|
| 97 |
+
"\n",
|
| 98 |
+
" .dataframe tbody tr th {\n",
|
| 99 |
+
" vertical-align: top;\n",
|
| 100 |
+
" }\n",
|
| 101 |
+
"\n",
|
| 102 |
+
" .dataframe thead th {\n",
|
| 103 |
+
" text-align: right;\n",
|
| 104 |
+
" }\n",
|
| 105 |
+
"</style>\n",
|
| 106 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 107 |
+
" <thead>\n",
|
| 108 |
+
" <tr style=\"text-align: right;\">\n",
|
| 109 |
+
" <th></th>\n",
|
| 110 |
+
" <th>split</th>\n",
|
| 111 |
+
" <th>treeoflife_id</th>\n",
|
| 112 |
+
" <th>eol_content_id_catalog</th>\n",
|
| 113 |
+
" <th>eol_page_id_catalog</th>\n",
|
| 114 |
+
" <th>kingdom</th>\n",
|
| 115 |
+
" <th>phylum</th>\n",
|
| 116 |
+
" <th>class</th>\n",
|
| 117 |
+
" <th>order</th>\n",
|
| 118 |
+
" <th>family</th>\n",
|
| 119 |
+
" <th>genus</th>\n",
|
| 120 |
+
" <th>species</th>\n",
|
| 121 |
+
" <th>common</th>\n",
|
| 122 |
+
" <th>combined_id_catalog</th>\n",
|
| 123 |
+
" </tr>\n",
|
| 124 |
+
" </thead>\n",
|
| 125 |
+
" <tbody>\n",
|
| 126 |
+
" <tr>\n",
|
| 127 |
+
" <th>956715</th>\n",
|
| 128 |
+
" <td>train</td>\n",
|
| 129 |
+
" <td>aa563519-6d97-47c3-bcda-c72cdf19a1bf</td>\n",
|
| 130 |
+
" <td>14855758</td>\n",
|
| 131 |
+
" <td>788082</td>\n",
|
| 132 |
+
" <td>Animalia</td>\n",
|
| 133 |
+
" <td>Arthropoda</td>\n",
|
| 134 |
+
" <td>Insecta</td>\n",
|
| 135 |
+
" <td>Diptera</td>\n",
|
| 136 |
+
" <td>Cecidomyiidae</td>\n",
|
| 137 |
+
" <td>Geocrypta</td>\n",
|
| 138 |
+
" <td>galii</td>\n",
|
| 139 |
+
" <td>Geocrypta galii</td>\n",
|
| 140 |
+
" <td>14855758_788082</td>\n",
|
| 141 |
+
" </tr>\n",
|
| 142 |
+
" <tr>\n",
|
| 143 |
+
" <th>956716</th>\n",
|
| 144 |
+
" <td>train</td>\n",
|
| 145 |
+
" <td>e3253a67-7114-41d5-ac55-1696d6c7f6f3</td>\n",
|
| 146 |
+
" <td>22807070</td>\n",
|
| 147 |
+
" <td>639017</td>\n",
|
| 148 |
+
" <td>Plantae</td>\n",
|
| 149 |
+
" <td>Tracheophyta</td>\n",
|
| 150 |
+
" <td>Magnoliopsida</td>\n",
|
| 151 |
+
" <td>Fabales</td>\n",
|
| 152 |
+
" <td>Fabaceae</td>\n",
|
| 153 |
+
" <td>Psoralea</td>\n",
|
| 154 |
+
" <td>lupinella</td>\n",
|
| 155 |
+
" <td>Psoralea lupinella</td>\n",
|
| 156 |
+
" <td>22807070_639017</td>\n",
|
| 157 |
+
" </tr>\n",
|
| 158 |
+
" </tbody>\n",
|
| 159 |
+
"</table>\n",
|
| 160 |
+
"</div>"
|
| 161 |
+
],
|
| 162 |
+
"text/plain": [
|
| 163 |
+
" split treeoflife_id eol_content_id_catalog \\\n",
|
| 164 |
+
"956715 train aa563519-6d97-47c3-bcda-c72cdf19a1bf 14855758 \n",
|
| 165 |
+
"956716 train e3253a67-7114-41d5-ac55-1696d6c7f6f3 22807070 \n",
|
| 166 |
+
"\n",
|
| 167 |
+
" eol_page_id_catalog kingdom phylum class order \\\n",
|
| 168 |
+
"956715 788082 Animalia Arthropoda Insecta Diptera \n",
|
| 169 |
+
"956716 639017 Plantae Tracheophyta Magnoliopsida Fabales \n",
|
| 170 |
+
"\n",
|
| 171 |
+
" family genus species common \\\n",
|
| 172 |
+
"956715 Cecidomyiidae Geocrypta galii Geocrypta galii \n",
|
| 173 |
+
"956716 Fabaceae Psoralea lupinella Psoralea lupinella \n",
|
| 174 |
+
"\n",
|
| 175 |
+
" combined_id_catalog \n",
|
| 176 |
+
"956715 14855758_788082 \n",
|
| 177 |
+
"956716 22807070_639017 "
|
| 178 |
+
]
|
| 179 |
+
},
|
| 180 |
+
"execution_count": 6,
|
| 181 |
+
"metadata": {},
|
| 182 |
+
"output_type": "execute_result"
|
| 183 |
+
}
|
| 184 |
+
],
|
| 185 |
+
"source": [
|
| 186 |
+
"# make combined ID for catalog and add suffix to eol content and page IDs\n",
|
| 187 |
+
"eol_catalog['combined_id_catalog'] = eol_catalog['eol_content_id'].astype(str) + '_' + eol_catalog['eol_page_id'].astype(str)\n",
|
| 188 |
+
"eol_catalog.rename(columns={'eol_content_id': 'eol_content_id_catalog', 'eol_page_id': 'eol_page_id_catalog'}, inplace=True)\n",
|
| 189 |
+
"eol_catalog.head(2)"
|
| 190 |
+
]
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"cell_type": "code",
|
| 194 |
+
"execution_count": 7,
|
| 195 |
+
"metadata": {},
|
| 196 |
+
"outputs": [
|
| 197 |
+
{
|
| 198 |
+
"name": "stdout",
|
| 199 |
+
"output_type": "stream",
|
| 200 |
+
"text": [
|
| 201 |
+
"archive has 6725471 entries, with columns: ['Filename', 'MD5']\n"
|
| 202 |
+
]
|
| 203 |
+
}
|
| 204 |
+
],
|
| 205 |
+
"source": [
|
| 206 |
+
"# Cargo had 6,724,838 entries\n",
|
| 207 |
+
"print(f\"archive has {archive.shape[0]} entries, with columns: {list(archive.columns)}\")"
|
| 208 |
+
]
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"cell_type": "code",
|
| 212 |
+
"execution_count": 8,
|
| 213 |
+
"metadata": {},
|
| 214 |
+
"outputs": [
|
| 215 |
+
{
|
| 216 |
+
"data": {
|
| 217 |
+
"text/html": [
|
| 218 |
+
"<div>\n",
|
| 219 |
+
"<style scoped>\n",
|
| 220 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 221 |
+
" vertical-align: middle;\n",
|
| 222 |
+
" }\n",
|
| 223 |
+
"\n",
|
| 224 |
+
" .dataframe tbody tr th {\n",
|
| 225 |
+
" vertical-align: top;\n",
|
| 226 |
+
" }\n",
|
| 227 |
+
"\n",
|
| 228 |
+
" .dataframe thead th {\n",
|
| 229 |
+
" text-align: right;\n",
|
| 230 |
+
" }\n",
|
| 231 |
+
"</style>\n",
|
| 232 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 233 |
+
" <thead>\n",
|
| 234 |
+
" <tr style=\"text-align: right;\">\n",
|
| 235 |
+
" <th></th>\n",
|
| 236 |
+
" <th>Filename</th>\n",
|
| 237 |
+
" <th>MD5</th>\n",
|
| 238 |
+
" </tr>\n",
|
| 239 |
+
" </thead>\n",
|
| 240 |
+
" <tbody>\n",
|
| 241 |
+
" <tr>\n",
|
| 242 |
+
" <th>0</th>\n",
|
| 243 |
+
" <td>29538374_65414274_eol-full-size-copy.jpg</td>\n",
|
| 244 |
+
" <td>98b1ed1430620ad50a6126cb2f9fcc74</td>\n",
|
| 245 |
+
" </tr>\n",
|
| 246 |
+
" <tr>\n",
|
| 247 |
+
" <th>1</th>\n",
|
| 248 |
+
" <td>27793900_888015_eol-full-size-copy.jpg</td>\n",
|
| 249 |
+
" <td>2de2ff12d5f339fe9d81a170749f9cb6</td>\n",
|
| 250 |
+
" </tr>\n",
|
| 251 |
+
" </tbody>\n",
|
| 252 |
+
"</table>\n",
|
| 253 |
+
"</div>"
|
| 254 |
+
],
|
| 255 |
+
"text/plain": [
|
| 256 |
+
" Filename MD5\n",
|
| 257 |
+
"0 29538374_65414274_eol-full-size-copy.jpg 98b1ed1430620ad50a6126cb2f9fcc74\n",
|
| 258 |
+
"1 27793900_888015_eol-full-size-copy.jpg 2de2ff12d5f339fe9d81a170749f9cb6"
|
| 259 |
+
]
|
| 260 |
+
},
|
| 261 |
+
"execution_count": 8,
|
| 262 |
+
"metadata": {},
|
| 263 |
+
"output_type": "execute_result"
|
| 264 |
+
}
|
| 265 |
+
],
|
| 266 |
+
"source": [
|
| 267 |
+
"archive.head(2)"
|
| 268 |
+
]
|
| 269 |
+
},
|
| 270 |
+
{
|
| 271 |
+
"cell_type": "code",
|
| 272 |
+
"execution_count": 9,
|
| 273 |
+
"metadata": {},
|
| 274 |
+
"outputs": [],
|
| 275 |
+
"source": [
|
| 276 |
+
"def get_combined_id(filename):\n",
|
| 277 |
+
" return filename.split(\"_e\")[0]"
|
| 278 |
+
]
|
| 279 |
+
},
|
| 280 |
+
{
|
| 281 |
+
"cell_type": "code",
|
| 282 |
+
"execution_count": 10,
|
| 283 |
+
"metadata": {},
|
| 284 |
+
"outputs": [],
|
| 285 |
+
"source": [
|
| 286 |
+
"archive[\"combined_id\"] = archive[\"Filename\"].apply(get_combined_id)"
|
| 287 |
+
]
|
| 288 |
+
},
|
| 289 |
+
{
|
| 290 |
+
"cell_type": "markdown",
|
| 291 |
+
"metadata": {},
|
| 292 |
+
"source": [
|
| 293 |
+
"Merge catalog with archive (sanity check on our images since the cargo didn't match with all of catalog)."
|
| 294 |
+
]
|
| 295 |
+
},
|
| 296 |
+
{
|
| 297 |
+
"cell_type": "code",
|
| 298 |
+
"execution_count": 11,
|
| 299 |
+
"metadata": {},
|
| 300 |
+
"outputs": [
|
| 301 |
+
{
|
| 302 |
+
"name": "stdout",
|
| 303 |
+
"output_type": "stream",
|
| 304 |
+
"text": [
|
| 305 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 306 |
+
"RangeIndex: 6250420 entries, 0 to 6250419\n",
|
| 307 |
+
"Data columns (total 16 columns):\n",
|
| 308 |
+
" # Column Non-Null Count Dtype \n",
|
| 309 |
+
"--- ------ -------------- ----- \n",
|
| 310 |
+
" 0 split 6250420 non-null object\n",
|
| 311 |
+
" 1 treeoflife_id 6250420 non-null object\n",
|
| 312 |
+
" 2 eol_content_id_catalog 6250420 non-null int64 \n",
|
| 313 |
+
" 3 eol_page_id_catalog 6250420 non-null int64 \n",
|
| 314 |
+
" 4 kingdom 5989611 non-null object\n",
|
| 315 |
+
" 5 phylum 5991207 non-null object\n",
|
| 316 |
+
" 6 class 5971438 non-null object\n",
|
| 317 |
+
" 7 order 5965299 non-null object\n",
|
| 318 |
+
" 8 family 5948728 non-null object\n",
|
| 319 |
+
" 9 genus 5940313 non-null object\n",
|
| 320 |
+
" 10 species 5951613 non-null object\n",
|
| 321 |
+
" 11 common 6250420 non-null object\n",
|
| 322 |
+
" 12 combined_id_catalog 6250420 non-null object\n",
|
| 323 |
+
" 13 Filename 6250420 non-null object\n",
|
| 324 |
+
" 14 MD5 6250420 non-null object\n",
|
| 325 |
+
" 15 combined_id 6250420 non-null object\n",
|
| 326 |
+
"dtypes: int64(2), object(14)\n",
|
| 327 |
+
"memory usage: 763.0+ MB\n"
|
| 328 |
+
]
|
| 329 |
+
}
|
| 330 |
+
],
|
| 331 |
+
"source": [
|
| 332 |
+
"catalog_archive = pd.merge(eol_catalog,\n",
|
| 333 |
+
" archive,\n",
|
| 334 |
+
" left_on = \"combined_id_catalog\",\n",
|
| 335 |
+
" right_on = \"combined_id\",\n",
|
| 336 |
+
" how=\"inner\"\n",
|
| 337 |
+
" )\n",
|
| 338 |
+
"catalog_archive.info(show_counts = True)"
|
| 339 |
+
]
|
| 340 |
+
},
|
| 341 |
+
{
|
| 342 |
+
"cell_type": "markdown",
|
| 343 |
+
"metadata": {},
|
| 344 |
+
"source": [
|
| 345 |
+
"Sanity check confirmed: Everything in the catalog is captured in our cargo archive."
|
| 346 |
+
]
|
| 347 |
+
},
|
| 348 |
+
{
|
| 349 |
+
"cell_type": "markdown",
|
| 350 |
+
"metadata": {},
|
| 351 |
+
"source": [
|
| 352 |
+
"Pull in combined manifest with checksums to merge on the archive checksums."
|
| 353 |
+
]
|
| 354 |
+
},
|
| 355 |
+
{
|
| 356 |
+
"cell_type": "code",
|
| 357 |
+
"execution_count": 12,
|
| 358 |
+
"metadata": {},
|
| 359 |
+
"outputs": [
|
| 360 |
+
{
|
| 361 |
+
"data": {
|
| 362 |
+
"text/plain": [
|
| 363 |
+
"Index(['filename_manifest', 'md5_combined_manifest',\n",
|
| 364 |
+
" 'combined_id_manifest_redownload', 'eol_content_id', 'eol_page_id',\n",
|
| 365 |
+
" 'medium_source_url', 'eol_full_size_copy_url', 'license_name',\n",
|
| 366 |
+
" 'copyright_owner', 'expected_image_filename', 'source_0706',\n",
|
| 367 |
+
" 'source_0726', 'source_1206', 'combined_id_full_manifest'],\n",
|
| 368 |
+
" dtype='object')"
|
| 369 |
+
]
|
| 370 |
+
},
|
| 371 |
+
"execution_count": 12,
|
| 372 |
+
"metadata": {},
|
| 373 |
+
"output_type": "execute_result"
|
| 374 |
+
}
|
| 375 |
+
],
|
| 376 |
+
"source": [
|
| 377 |
+
"manifests = pd.read_csv(\"../data/combined_manifest_with_checksums.csv\", low_memory=False)\n",
|
| 378 |
+
"manifests.columns"
|
| 379 |
+
]
|
| 380 |
+
},
|
| 381 |
+
{
|
| 382 |
+
"cell_type": "code",
|
| 383 |
+
"execution_count": 13,
|
| 384 |
+
"metadata": {},
|
| 385 |
+
"outputs": [
|
| 386 |
+
{
|
| 387 |
+
"name": "stdout",
|
| 388 |
+
"output_type": "stream",
|
| 389 |
+
"text": [
|
| 390 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 391 |
+
"RangeIndex: 6841202 entries, 0 to 6841201\n",
|
| 392 |
+
"Data columns (total 30 columns):\n",
|
| 393 |
+
" # Column Non-Null Count Dtype \n",
|
| 394 |
+
"--- ------ -------------- ----- \n",
|
| 395 |
+
" 0 split 6841202 non-null object\n",
|
| 396 |
+
" 1 treeoflife_id 6841202 non-null object\n",
|
| 397 |
+
" 2 eol_content_id_catalog 6841202 non-null int64 \n",
|
| 398 |
+
" 3 eol_page_id_catalog 6841202 non-null int64 \n",
|
| 399 |
+
" 4 kingdom 6551473 non-null object\n",
|
| 400 |
+
" 5 phylum 6553206 non-null object\n",
|
| 401 |
+
" 6 class 6532009 non-null object\n",
|
| 402 |
+
" 7 order 6525621 non-null object\n",
|
| 403 |
+
" 8 family 6506076 non-null object\n",
|
| 404 |
+
" 9 genus 6486130 non-null object\n",
|
| 405 |
+
" 10 species 6406307 non-null object\n",
|
| 406 |
+
" 11 common 6841202 non-null object\n",
|
| 407 |
+
" 12 combined_id_catalog 6841202 non-null object\n",
|
| 408 |
+
" 13 Filename 6841202 non-null object\n",
|
| 409 |
+
" 14 MD5 6841202 non-null object\n",
|
| 410 |
+
" 15 combined_id 6841202 non-null object\n",
|
| 411 |
+
" 16 filename_manifest 6841202 non-null object\n",
|
| 412 |
+
" 17 md5_combined_manifest 6841202 non-null object\n",
|
| 413 |
+
" 18 combined_id_manifest_redownload 6841202 non-null object\n",
|
| 414 |
+
" 19 eol_content_id 6841202 non-null int64 \n",
|
| 415 |
+
" 20 eol_page_id 6841202 non-null int64 \n",
|
| 416 |
+
" 21 medium_source_url 6841202 non-null object\n",
|
| 417 |
+
" 22 eol_full_size_copy_url 6841202 non-null object\n",
|
| 418 |
+
" 23 license_name 6841202 non-null object\n",
|
| 419 |
+
" 24 copyright_owner 6208498 non-null object\n",
|
| 420 |
+
" 25 expected_image_filename 6841202 non-null object\n",
|
| 421 |
+
" 26 source_0706 6841202 non-null bool \n",
|
| 422 |
+
" 27 source_0726 6841202 non-null bool \n",
|
| 423 |
+
" 28 source_1206 6841202 non-null bool \n",
|
| 424 |
+
" 29 combined_id_full_manifest 6841202 non-null object\n",
|
| 425 |
+
"dtypes: bool(3), int64(4), object(23)\n",
|
| 426 |
+
"memory usage: 1.4+ GB\n"
|
| 427 |
+
]
|
| 428 |
+
}
|
| 429 |
+
],
|
| 430 |
+
"source": [
|
| 431 |
+
"catalog_archive_manifest = pd.merge(catalog_archive,\n",
|
| 432 |
+
" manifests,\n",
|
| 433 |
+
" left_on = \"MD5\",\n",
|
| 434 |
+
" right_on = \"md5_combined_manifest\",\n",
|
| 435 |
+
" how = \"inner\",\n",
|
| 436 |
+
" suffixes=(\"\",\"_manifests\")\n",
|
| 437 |
+
" )\n",
|
| 438 |
+
"catalog_archive_manifest.info(show_counts = True)"
|
| 439 |
+
]
|
| 440 |
+
},
|
| 441 |
+
{
|
| 442 |
+
"cell_type": "code",
|
| 443 |
+
"execution_count": 14,
|
| 444 |
+
"metadata": {},
|
| 445 |
+
"outputs": [
|
| 446 |
+
{
|
| 447 |
+
"data": {
|
| 448 |
+
"text/plain": [
|
| 449 |
+
"6219674"
|
| 450 |
+
]
|
| 451 |
+
},
|
| 452 |
+
"execution_count": 14,
|
| 453 |
+
"metadata": {},
|
| 454 |
+
"output_type": "execute_result"
|
| 455 |
+
}
|
| 456 |
+
],
|
| 457 |
+
"source": [
|
| 458 |
+
"catalog_archive_manifest.treeoflife_id.nunique()"
|
| 459 |
+
]
|
| 460 |
+
},
|
| 461 |
+
{
|
| 462 |
+
"cell_type": "markdown",
|
| 463 |
+
"metadata": {},
|
| 464 |
+
"source": [
|
| 465 |
+
"Only 6,219,674 of our 6,250,420 images were able to be pulled through the combined manifests."
|
| 466 |
+
]
|
| 467 |
+
},
|
| 468 |
+
{
|
| 469 |
+
"cell_type": "code",
|
| 470 |
+
"execution_count": null,
|
| 471 |
+
"metadata": {},
|
| 472 |
+
"outputs": [],
|
| 473 |
+
"source": []
|
| 474 |
+
}
|
| 475 |
+
],
|
| 476 |
+
"metadata": {
|
| 477 |
+
"kernelspec": {
|
| 478 |
+
"display_name": "std",
|
| 479 |
+
"language": "python",
|
| 480 |
+
"name": "python3"
|
| 481 |
+
},
|
| 482 |
+
"language_info": {
|
| 483 |
+
"codemirror_mode": {
|
| 484 |
+
"name": "ipython",
|
| 485 |
+
"version": 3
|
| 486 |
+
},
|
| 487 |
+
"file_extension": ".py",
|
| 488 |
+
"mimetype": "text/x-python",
|
| 489 |
+
"name": "python",
|
| 490 |
+
"nbconvert_exporter": "python",
|
| 491 |
+
"pygments_lexer": "ipython3",
|
| 492 |
+
"version": "3.11.3"
|
| 493 |
+
}
|
| 494 |
+
},
|
| 495 |
+
"nbformat": 4,
|
| 496 |
+
"nbformat_minor": 2
|
| 497 |
+
}
|