egrace479 commited on
Commit
137ddb8
·
1 Parent(s): d6d52e2

Makes file with media manifest content IDs not in predicted catalog for MD5 checks.

Browse files
notebooks/ToL_media_mismatch.ipynb CHANGED
@@ -277,7 +277,7 @@
277
  },
278
  {
279
  "cell_type": "code",
280
- "execution_count": 5,
281
  "metadata": {},
282
  "outputs": [],
283
  "source": [
@@ -296,7 +296,7 @@
296
  },
297
  {
298
  "cell_type": "code",
299
- "execution_count": 6,
300
  "metadata": {},
301
  "outputs": [],
302
  "source": [
@@ -514,7 +514,7 @@
514
  },
515
  {
516
  "cell_type": "code",
517
- "execution_count": 8,
518
  "metadata": {},
519
  "outputs": [
520
  {
@@ -523,7 +523,7 @@
523
  "Index(['treeoflife_id', 'eol_content_id', 'eol_page_id'], dtype='object')"
524
  ]
525
  },
526
- "execution_count": 8,
527
  "metadata": {},
528
  "output_type": "execute_result"
529
  }
@@ -535,7 +535,7 @@
535
  },
536
  {
537
  "cell_type": "code",
538
- "execution_count": 9,
539
  "metadata": {},
540
  "outputs": [],
541
  "source": [
@@ -544,7 +544,7 @@
544
  },
545
  {
546
  "cell_type": "code",
547
- "execution_count": 10,
548
  "metadata": {},
549
  "outputs": [
550
  {
@@ -556,7 +556,7 @@
556
  "dtype: int64"
557
  ]
558
  },
559
- "execution_count": 10,
560
  "metadata": {},
561
  "output_type": "execute_result"
562
  }
@@ -582,7 +582,7 @@
582
  },
583
  {
584
  "cell_type": "code",
585
- "execution_count": 11,
586
  "metadata": {},
587
  "outputs": [
588
  {
@@ -619,7 +619,7 @@
619
  },
620
  {
621
  "cell_type": "code",
622
- "execution_count": 12,
623
  "metadata": {},
624
  "outputs": [
625
  {
@@ -660,7 +660,7 @@
660
  },
661
  {
662
  "cell_type": "code",
663
- "execution_count": 13,
664
  "metadata": {},
665
  "outputs": [],
666
  "source": [
@@ -676,7 +676,7 @@
676
  },
677
  {
678
  "cell_type": "code",
679
- "execution_count": 14,
680
  "metadata": {},
681
  "outputs": [],
682
  "source": [
@@ -685,7 +685,7 @@
685
  },
686
  {
687
  "cell_type": "code",
688
- "execution_count": 15,
689
  "metadata": {},
690
  "outputs": [
691
  {
@@ -998,6 +998,297 @@
998
  "eol_df_missing_media.to_csv(\"../data/eol_files/eol_cp_not_media.csv\", index = False)"
999
  ]
1000
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1001
  {
1002
  "cell_type": "markdown",
1003
  "metadata": {},
 
277
  },
278
  {
279
  "cell_type": "code",
280
+ "execution_count": 3,
281
  "metadata": {},
282
  "outputs": [],
283
  "source": [
 
296
  },
297
  {
298
  "cell_type": "code",
299
+ "execution_count": 4,
300
  "metadata": {},
301
  "outputs": [],
302
  "source": [
 
514
  },
515
  {
516
  "cell_type": "code",
517
+ "execution_count": 5,
518
  "metadata": {},
519
  "outputs": [
520
  {
 
523
  "Index(['treeoflife_id', 'eol_content_id', 'eol_page_id'], dtype='object')"
524
  ]
525
  },
526
+ "execution_count": 5,
527
  "metadata": {},
528
  "output_type": "execute_result"
529
  }
 
535
  },
536
  {
537
  "cell_type": "code",
538
+ "execution_count": 6,
539
  "metadata": {},
540
  "outputs": [],
541
  "source": [
 
544
  },
545
  {
546
  "cell_type": "code",
547
+ "execution_count": 7,
548
  "metadata": {},
549
  "outputs": [
550
  {
 
556
  "dtype: int64"
557
  ]
558
  },
559
+ "execution_count": 7,
560
  "metadata": {},
561
  "output_type": "execute_result"
562
  }
 
582
  },
583
  {
584
  "cell_type": "code",
585
+ "execution_count": 8,
586
  "metadata": {},
587
  "outputs": [
588
  {
 
619
  },
620
  {
621
  "cell_type": "code",
622
+ "execution_count": 9,
623
  "metadata": {},
624
  "outputs": [
625
  {
 
660
  },
661
  {
662
  "cell_type": "code",
663
+ "execution_count": 10,
664
  "metadata": {},
665
  "outputs": [],
666
  "source": [
 
676
  },
677
  {
678
  "cell_type": "code",
679
+ "execution_count": 11,
680
  "metadata": {},
681
  "outputs": [],
682
  "source": [
 
685
  },
686
  {
687
  "cell_type": "code",
688
+ "execution_count": 12,
689
  "metadata": {},
690
  "outputs": [
691
  {
 
998
  "eol_df_missing_media.to_csv(\"../data/eol_files/eol_cp_not_media.csv\", index = False)"
999
  ]
1000
  },
1001
+ {
1002
+ "cell_type": "markdown",
1003
+ "metadata": {},
1004
+ "source": [
1005
+ "### Get Content IDs in Media Manifest that didn't match \n"
1006
+ ]
1007
+ },
1008
+ {
1009
+ "cell_type": "code",
1010
+ "execution_count": 13,
1011
+ "metadata": {},
1012
+ "outputs": [
1013
+ {
1014
+ "data": {
1015
+ "text/plain": [
1016
+ "[22131926, 22291283, 21802775, 12784812, 29713643]"
1017
+ ]
1018
+ },
1019
+ "execution_count": 13,
1020
+ "metadata": {},
1021
+ "output_type": "execute_result"
1022
+ }
1023
+ ],
1024
+ "source": [
1025
+ "content_ids_in_catalog = list(eol_df_media_cp.eol_content_id)\n",
1026
+ "content_ids_in_catalog[:5]"
1027
+ ]
1028
+ },
1029
+ {
1030
+ "cell_type": "code",
1031
+ "execution_count": 14,
1032
+ "metadata": {},
1033
+ "outputs": [
1034
+ {
1035
+ "name": "stdout",
1036
+ "output_type": "stream",
1037
+ "text": [
1038
+ "<class 'pandas.core.frame.DataFrame'>\n",
1039
+ "Index: 410321 entries, 65 to 6574223\n",
1040
+ "Data columns (total 6 columns):\n",
1041
+ " # Column Non-Null Count Dtype \n",
1042
+ "--- ------ -------------- ----- \n",
1043
+ " 0 eol_content_id 410321 non-null int64 \n",
1044
+ " 1 eol_page_id 410321 non-null int64 \n",
1045
+ " 2 Medium Source URL 410319 non-null object\n",
1046
+ " 3 EOL Full-Size Copy URL 410321 non-null object\n",
1047
+ " 4 License Name 410321 non-null object\n",
1048
+ " 5 Copyright Owner 392753 non-null object\n",
1049
+ "dtypes: int64(2), object(4)\n",
1050
+ "memory usage: 21.9+ MB\n"
1051
+ ]
1052
+ }
1053
+ ],
1054
+ "source": [
1055
+ "media_missing_tol = media.loc[~media.eol_content_id.isin(content_ids_in_catalog)]\n",
1056
+ "media_missing_tol.info(show_counts = True)"
1057
+ ]
1058
+ },
1059
+ {
1060
+ "cell_type": "code",
1061
+ "execution_count": 15,
1062
+ "metadata": {},
1063
+ "outputs": [],
1064
+ "source": [
1065
+ "# Save media manifest content IDs that didn't match to predicted-catalog\n",
1066
+ "media_missing_tol.to_csv(\"../data/eol_files/media_content_not_catalog.csv\", index = False)"
1067
+ ]
1068
+ },
1069
+ {
1070
+ "cell_type": "markdown",
1071
+ "metadata": {},
1072
+ "source": [
1073
+ "#### Compare to Dec 6 Media Manifest"
1074
+ ]
1075
+ },
1076
+ {
1077
+ "cell_type": "code",
1078
+ "execution_count": 16,
1079
+ "metadata": {},
1080
+ "outputs": [
1081
+ {
1082
+ "name": "stdout",
1083
+ "output_type": "stream",
1084
+ "text": [
1085
+ "<class 'pandas.core.frame.DataFrame'>\n",
1086
+ "RangeIndex: 6576247 entries, 0 to 6576246\n",
1087
+ "Data columns (total 6 columns):\n",
1088
+ " # Column Non-Null Count Dtype \n",
1089
+ "--- ------ -------------- ----- \n",
1090
+ " 0 EOL content ID 6576247 non-null int64 \n",
1091
+ " 1 EOL page ID 6576247 non-null int64 \n",
1092
+ " 2 Medium Source URL 6576245 non-null object\n",
1093
+ " 3 EOL Full-Size Copy URL 6576247 non-null object\n",
1094
+ " 4 License Name 6576247 non-null object\n",
1095
+ " 5 Copyright Owner 5944184 non-null object\n",
1096
+ "dtypes: int64(2), object(4)\n",
1097
+ "memory usage: 301.0+ MB\n"
1098
+ ]
1099
+ }
1100
+ ],
1101
+ "source": [
1102
+ "dec_media = pd.read_csv(\"../data/media_manifest_Dec6.csv\", dtype = {\"EOL content ID\": \"int64\", \"EOL page ID\": \"int64\"}, low_memory = False)\n",
1103
+ "dec_media.info(show_counts = True)"
1104
+ ]
1105
+ },
1106
+ {
1107
+ "cell_type": "markdown",
1108
+ "metadata": {},
1109
+ "source": [
1110
+ "Only about 2000 more images than July 26 media manifest."
1111
+ ]
1112
+ },
1113
+ {
1114
+ "cell_type": "code",
1115
+ "execution_count": 17,
1116
+ "metadata": {},
1117
+ "outputs": [],
1118
+ "source": [
1119
+ "dec_media.rename(columns = {\"EOL content ID\": \"eol_content_id\", \"EOL page ID\": \"eol_page_id\"}, inplace = True)"
1120
+ ]
1121
+ },
1122
+ {
1123
+ "cell_type": "code",
1124
+ "execution_count": 18,
1125
+ "metadata": {},
1126
+ "outputs": [
1127
+ {
1128
+ "name": "stdout",
1129
+ "output_type": "stream",
1130
+ "text": [
1131
+ "<class 'pandas.core.frame.DataFrame'>\n",
1132
+ "RangeIndex: 5796323 entries, 0 to 5796322\n",
1133
+ "Data columns (total 7 columns):\n",
1134
+ " # Column Non-Null Count Dtype \n",
1135
+ "--- ------ -------------- ----- \n",
1136
+ " 0 treeoflife_id 5796323 non-null object\n",
1137
+ " 1 eol_content_id 5796323 non-null int64 \n",
1138
+ " 2 eol_page_id 5796323 non-null int64 \n",
1139
+ " 3 Medium Source URL 5796323 non-null object\n",
1140
+ " 4 EOL Full-Size Copy URL 5796323 non-null object\n",
1141
+ " 5 License Name 5796323 non-null object\n",
1142
+ " 6 Copyright Owner 5189325 non-null object\n",
1143
+ "dtypes: int64(2), object(5)\n",
1144
+ "memory usage: 309.6+ MB\n"
1145
+ ]
1146
+ }
1147
+ ],
1148
+ "source": [
1149
+ "eol_dec_media_cp = pd.merge(eol_df, dec_media, how = \"inner\", left_on = merge_cols, right_on = merge_cols)\n",
1150
+ "eol_dec_media_cp.info(show_counts = True)"
1151
+ ]
1152
+ },
1153
+ {
1154
+ "cell_type": "markdown",
1155
+ "metadata": {},
1156
+ "source": [
1157
+ "And we have _less_ matching....Let's compare this to the July 26 manifest and see if there are content IDs only in Dec that do match to predicted-catalog."
1158
+ ]
1159
+ },
1160
+ {
1161
+ "cell_type": "code",
1162
+ "execution_count": 19,
1163
+ "metadata": {},
1164
+ "outputs": [
1165
+ {
1166
+ "name": "stdout",
1167
+ "output_type": "stream",
1168
+ "text": [
1169
+ "<class 'pandas.core.frame.DataFrame'>\n",
1170
+ "RangeIndex: 6021614 entries, 0 to 6021613\n",
1171
+ "Data columns (total 10 columns):\n",
1172
+ " # Column Non-Null Count Dtype \n",
1173
+ "--- ------ -------------- ----- \n",
1174
+ " 0 eol_content_id 6021614 non-null int64 \n",
1175
+ " 1 eol_page_id 6021614 non-null int64 \n",
1176
+ " 2 Medium Source URL_x 6021612 non-null object\n",
1177
+ " 3 EOL Full-Size Copy URL_x 6021614 non-null object\n",
1178
+ " 4 License Name_x 6021614 non-null object\n",
1179
+ " 5 Copyright Owner_x 5399986 non-null object\n",
1180
+ " 6 Medium Source URL_y 6021612 non-null object\n",
1181
+ " 7 EOL Full-Size Copy URL_y 6021614 non-null object\n",
1182
+ " 8 License Name_y 6021614 non-null object\n",
1183
+ " 9 Copyright Owner_y 5399986 non-null object\n",
1184
+ "dtypes: int64(2), object(8)\n",
1185
+ "memory usage: 459.4+ MB\n"
1186
+ ]
1187
+ }
1188
+ ],
1189
+ "source": [
1190
+ "media_merge = pd.merge(dec_media, media, how = \"inner\", left_on = merge_cols, right_on = merge_cols)\n",
1191
+ "media_merge.info(show_counts = True)"
1192
+ ]
1193
+ },
1194
+ {
1195
+ "cell_type": "code",
1196
+ "execution_count": 20,
1197
+ "metadata": {},
1198
+ "outputs": [
1199
+ {
1200
+ "data": {
1201
+ "text/plain": [
1202
+ "[5470022, 5470023, 5470024, 5470025, 5470026]"
1203
+ ]
1204
+ },
1205
+ "execution_count": 20,
1206
+ "metadata": {},
1207
+ "output_type": "execute_result"
1208
+ }
1209
+ ],
1210
+ "source": [
1211
+ "content_ids_both_media = list(media_merge.eol_content_id)\n",
1212
+ "content_ids_both_media[:5]"
1213
+ ]
1214
+ },
1215
+ {
1216
+ "cell_type": "code",
1217
+ "execution_count": 22,
1218
+ "metadata": {},
1219
+ "outputs": [
1220
+ {
1221
+ "name": "stdout",
1222
+ "output_type": "stream",
1223
+ "text": [
1224
+ "<class 'pandas.core.frame.DataFrame'>\n",
1225
+ "Index: 554633 entries, 6021614 to 6576246\n",
1226
+ "Data columns (total 6 columns):\n",
1227
+ " # Column Non-Null Count Dtype \n",
1228
+ "--- ------ -------------- ----- \n",
1229
+ " 0 eol_content_id 554633 non-null int64 \n",
1230
+ " 1 eol_page_id 554633 non-null int64 \n",
1231
+ " 2 Medium Source URL 554633 non-null object\n",
1232
+ " 3 EOL Full-Size Copy URL 554633 non-null object\n",
1233
+ " 4 License Name 554633 non-null object\n",
1234
+ " 5 Copyright Owner 544198 non-null object\n",
1235
+ "dtypes: int64(2), object(4)\n",
1236
+ "memory usage: 29.6+ MB\n"
1237
+ ]
1238
+ }
1239
+ ],
1240
+ "source": [
1241
+ "media_dec_notJuly = dec_media.loc[~dec_media.eol_content_id.isin(content_ids_both_media)]\n",
1242
+ "media_dec_notJuly.info(show_counts = True)"
1243
+ ]
1244
+ },
1245
+ {
1246
+ "cell_type": "markdown",
1247
+ "metadata": {},
1248
+ "source": [
1249
+ "Let's see if any of these are in our predicted catalog."
1250
+ ]
1251
+ },
1252
+ {
1253
+ "cell_type": "code",
1254
+ "execution_count": 23,
1255
+ "metadata": {},
1256
+ "outputs": [
1257
+ {
1258
+ "name": "stdout",
1259
+ "output_type": "stream",
1260
+ "text": [
1261
+ "<class 'pandas.core.frame.DataFrame'>\n",
1262
+ "RangeIndex: 0 entries\n",
1263
+ "Data columns (total 7 columns):\n",
1264
+ " # Column Non-Null Count Dtype \n",
1265
+ "--- ------ -------------- ----- \n",
1266
+ " 0 treeoflife_id 0 non-null object\n",
1267
+ " 1 eol_content_id 0 non-null int64 \n",
1268
+ " 2 eol_page_id 0 non-null int64 \n",
1269
+ " 3 Medium Source URL 0 non-null object\n",
1270
+ " 4 EOL Full-Size Copy URL 0 non-null object\n",
1271
+ " 5 License Name 0 non-null object\n",
1272
+ " 6 Copyright Owner 0 non-null object\n",
1273
+ "dtypes: int64(2), object(5)\n",
1274
+ "memory usage: 132.0+ bytes\n"
1275
+ ]
1276
+ }
1277
+ ],
1278
+ "source": [
1279
+ "eol_dec_only = pd.merge(eol_df, media_dec_notJuly, how = \"inner\", left_on = merge_cols, right_on = merge_cols)\n",
1280
+ "eol_dec_only.info(show_counts = True)"
1281
+ ]
1282
+ },
1283
+ {
1284
+ "cell_type": "markdown",
1285
+ "metadata": {},
1286
+ "source": [
1287
+ "Okay, no matches here, so stick with July 26 file above, this doesn't help us recoup.\n",
1288
+ "\n",
1289
+ "Old media manifest (July 6) won't read EOL content and page IDs in properly, so can't check that against these."
1290
+ ]
1291
+ },
1292
  {
1293
  "cell_type": "markdown",
1294
  "metadata": {},
notebooks/ToL_media_mismatch.py CHANGED
@@ -153,6 +153,66 @@ eol_df_missing_media.nunique()
153
  # %%
154
  eol_df_missing_media.to_csv("../data/eol_files/eol_cp_not_media.csv", index = False)
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  # %% [markdown]
157
  # ### Check out the Duplication of Medium Source URLs
158
 
 
153
  # %%
154
  eol_df_missing_media.to_csv("../data/eol_files/eol_cp_not_media.csv", index = False)
155
 
156
+ # %% [markdown]
157
+ # ### Get Content IDs in Media Manifest that didn't match
158
+ #
159
+
160
+ # %%
161
+ content_ids_in_catalog = list(eol_df_media_cp.eol_content_id)
162
+ content_ids_in_catalog[:5]
163
+
164
+ # %%
165
+ media_missing_tol = media.loc[~media.eol_content_id.isin(content_ids_in_catalog)]
166
+ media_missing_tol.info(show_counts = True)
167
+
168
+ # %%
169
+ # Save media manifest content IDs that didn't match to predicted-catalog
170
+ media_missing_tol.to_csv("../data/eol_files/media_content_not_catalog.csv", index = False)
171
+
172
+ # %% [markdown]
173
+ # #### Compare to Dec 6 Media Manifest
174
+
175
+ # %%
176
+ dec_media = pd.read_csv("../data/media_manifest_Dec6.csv", dtype = {"EOL content ID": "int64", "EOL page ID": "int64"}, low_memory = False)
177
+ dec_media.info(show_counts = True)
178
+
179
+ # %% [markdown]
180
+ # Only about 2000 more images than July 26 media manifest.
181
+
182
+ # %%
183
+ dec_media.rename(columns = {"EOL content ID": "eol_content_id", "EOL page ID": "eol_page_id"}, inplace = True)
184
+
185
+ # %%
186
+ eol_dec_media_cp = pd.merge(eol_df, dec_media, how = "inner", left_on = merge_cols, right_on = merge_cols)
187
+ eol_dec_media_cp.info(show_counts = True)
188
+
189
+ # %% [markdown]
190
+ # And we have _less_ matching....Let's compare this to the July 26 manifest and see if there are content IDs only in Dec that do match to predicted-catalog.
191
+
192
+ # %%
193
+ media_merge = pd.merge(dec_media, media, how = "inner", left_on = merge_cols, right_on = merge_cols)
194
+ media_merge.info(show_counts = True)
195
+
196
+ # %%
197
+ content_ids_both_media = list(media_merge.eol_content_id)
198
+ content_ids_both_media[:5]
199
+
200
+ # %%
201
+ media_dec_notJuly = dec_media.loc[~dec_media.eol_content_id.isin(content_ids_both_media)]
202
+ media_dec_notJuly.info(show_counts = True)
203
+
204
+ # %% [markdown]
205
+ # Let's see if any of these are in our predicted catalog.
206
+
207
+ # %%
208
+ eol_dec_only = pd.merge(eol_df, media_dec_notJuly, how = "inner", left_on = merge_cols, right_on = merge_cols)
209
+ eol_dec_only.info(show_counts = True)
210
+
211
+ # %% [markdown]
212
+ # Okay, no matches here, so stick with July 26 file above, this doesn't help us recoup.
213
+ #
214
+ # Old media manifest (July 6) won't read EOL content and page IDs in properly, so can't check that against these.
215
+
216
  # %% [markdown]
217
  # ### Check out the Duplication of Medium Source URLs
218