Add common name to rarespecies-catalog
Browse filesDone at end of re-gen_rs_catalog notebook.
eol_realign/notebooks/re-gen_rs_catalog.ipynb
CHANGED
|
@@ -1087,6 +1087,411 @@
|
|
| 1087 |
"updated_catalog.to_csv(RS_FILEPATH + \"rarespecies-catalog.csv\", index = False)"
|
| 1088 |
]
|
| 1089 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1090 |
{
|
| 1091 |
"cell_type": "code",
|
| 1092 |
"execution_count": null,
|
|
|
|
| 1087 |
"updated_catalog.to_csv(RS_FILEPATH + \"rarespecies-catalog.csv\", index = False)"
|
| 1088 |
]
|
| 1089 |
},
|
| 1090 |
+
{
|
| 1091 |
+
"cell_type": "markdown",
|
| 1092 |
+
"metadata": {},
|
| 1093 |
+
"source": [
|
| 1094 |
+
"## Add common name column\n",
|
| 1095 |
+
"\n",
|
| 1096 |
+
"Common names have now been requested, so we'll pull those in (from [`predicted-catalog.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/main/data/predicted-catalog.csv), [v3.3](https://huggingface.co/datasets/imageomics/ToL-EDA/commit/5260e84802d2910eedc2a206e7be035cf28f64d4)).\n",
|
| 1097 |
+
"\n",
|
| 1098 |
+
"Updating [`rarespecies-catalog.csv`](https://huggingface.co/datasets/imageomics/ToL-EDA/blob/49400c376e62866be1c5038b673d2ebb002c0540/rare_species/data/rarespecies-catalog.csv)."
|
| 1099 |
+
]
|
| 1100 |
+
},
|
| 1101 |
+
{
|
| 1102 |
+
"cell_type": "code",
|
| 1103 |
+
"execution_count": 5,
|
| 1104 |
+
"metadata": {},
|
| 1105 |
+
"outputs": [],
|
| 1106 |
+
"source": [
|
| 1107 |
+
"# pull our updated catalog back in\n",
|
| 1108 |
+
"updated_catalog = pd.read_csv(RS_FILEPATH + \"rarespecies-catalog.csv\",\n",
|
| 1109 |
+
" low_memory=False,\n",
|
| 1110 |
+
" dtype = {\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"})"
|
| 1111 |
+
]
|
| 1112 |
+
},
|
| 1113 |
+
{
|
| 1114 |
+
"cell_type": "code",
|
| 1115 |
+
"execution_count": 4,
|
| 1116 |
+
"metadata": {},
|
| 1117 |
+
"outputs": [],
|
| 1118 |
+
"source": [
|
| 1119 |
+
"pred_cat = pd.read_csv(\"../../data/predicted-catalog.csv\", low_memory=False)"
|
| 1120 |
+
]
|
| 1121 |
+
},
|
| 1122 |
+
{
|
| 1123 |
+
"cell_type": "markdown",
|
| 1124 |
+
"metadata": {},
|
| 1125 |
+
"source": [
|
| 1126 |
+
"Reduce to just images sourced from EOL, cast content and page ids to `int64` for proper matching (will check there aren't different common name labels for some entries), then reduce to just Rare Species pages."
|
| 1127 |
+
]
|
| 1128 |
+
},
|
| 1129 |
+
{
|
| 1130 |
+
"cell_type": "code",
|
| 1131 |
+
"execution_count": 7,
|
| 1132 |
+
"metadata": {},
|
| 1133 |
+
"outputs": [
|
| 1134 |
+
{
|
| 1135 |
+
"data": {
|
| 1136 |
+
"text/plain": [
|
| 1137 |
+
"eol_content_id 22580\n",
|
| 1138 |
+
"eol_page_id 400\n",
|
| 1139 |
+
"kingdom 1\n",
|
| 1140 |
+
"phylum 5\n",
|
| 1141 |
+
"class 15\n",
|
| 1142 |
+
"order 85\n",
|
| 1143 |
+
"family 202\n",
|
| 1144 |
+
"genus 316\n",
|
| 1145 |
+
"species 385\n",
|
| 1146 |
+
"common 398\n",
|
| 1147 |
+
"dtype: int64"
|
| 1148 |
+
]
|
| 1149 |
+
},
|
| 1150 |
+
"execution_count": 7,
|
| 1151 |
+
"metadata": {},
|
| 1152 |
+
"output_type": "execute_result"
|
| 1153 |
+
}
|
| 1154 |
+
],
|
| 1155 |
+
"source": [
|
| 1156 |
+
"eol_pred = pred_cat.loc[pred_cat[\"eol_content_id\"].notna()]\n",
|
| 1157 |
+
"eol_pred = eol_pred.astype({\"eol_content_id\": \"int64\", \"eol_page_id\": \"int64\"})\n",
|
| 1158 |
+
"rs_pred = eol_pred.loc[eol_pred[\"eol_page_id\"].isin(list(updated_catalog.eol_page_id.unique()))]\n",
|
| 1159 |
+
"\n",
|
| 1160 |
+
"cols_interest = list(updated_catalog.columns)[1:-1]\n",
|
| 1161 |
+
"cols_interest.append(\"common\")\n",
|
| 1162 |
+
"rs_pred[cols_interest].nunique()"
|
| 1163 |
+
]
|
| 1164 |
+
},
|
| 1165 |
+
{
|
| 1166 |
+
"cell_type": "markdown",
|
| 1167 |
+
"metadata": {},
|
| 1168 |
+
"source": [
|
| 1169 |
+
"We don't seem to have unique common names for all of these entries. Let's find out what's duplicated."
|
| 1170 |
+
]
|
| 1171 |
+
},
|
| 1172 |
+
{
|
| 1173 |
+
"cell_type": "code",
|
| 1174 |
+
"execution_count": 9,
|
| 1175 |
+
"metadata": {},
|
| 1176 |
+
"outputs": [
|
| 1177 |
+
{
|
| 1178 |
+
"name": "stderr",
|
| 1179 |
+
"output_type": "stream",
|
| 1180 |
+
"text": [
|
| 1181 |
+
"/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_63935/2578193768.py:1: SettingWithCopyWarning: \n",
|
| 1182 |
+
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
| 1183 |
+
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
| 1184 |
+
"\n",
|
| 1185 |
+
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
| 1186 |
+
" rs_pred[\"duplicate_page\"] = rs_pred.duplicated(\"eol_page_id\", keep = \"first\")\n"
|
| 1187 |
+
]
|
| 1188 |
+
},
|
| 1189 |
+
{
|
| 1190 |
+
"data": {
|
| 1191 |
+
"text/html": [
|
| 1192 |
+
"<div>\n",
|
| 1193 |
+
"<style scoped>\n",
|
| 1194 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1195 |
+
" vertical-align: middle;\n",
|
| 1196 |
+
" }\n",
|
| 1197 |
+
"\n",
|
| 1198 |
+
" .dataframe tbody tr th {\n",
|
| 1199 |
+
" vertical-align: top;\n",
|
| 1200 |
+
" }\n",
|
| 1201 |
+
"\n",
|
| 1202 |
+
" .dataframe thead th {\n",
|
| 1203 |
+
" text-align: right;\n",
|
| 1204 |
+
" }\n",
|
| 1205 |
+
"</style>\n",
|
| 1206 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1207 |
+
" <thead>\n",
|
| 1208 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1209 |
+
" <th></th>\n",
|
| 1210 |
+
" <th>eol_content_id</th>\n",
|
| 1211 |
+
" <th>eol_page_id</th>\n",
|
| 1212 |
+
" <th>kingdom</th>\n",
|
| 1213 |
+
" <th>phylum</th>\n",
|
| 1214 |
+
" <th>class</th>\n",
|
| 1215 |
+
" <th>order</th>\n",
|
| 1216 |
+
" <th>family</th>\n",
|
| 1217 |
+
" <th>genus</th>\n",
|
| 1218 |
+
" <th>species</th>\n",
|
| 1219 |
+
" <th>common</th>\n",
|
| 1220 |
+
" <th>duplicate_common</th>\n",
|
| 1221 |
+
" </tr>\n",
|
| 1222 |
+
" </thead>\n",
|
| 1223 |
+
" <tbody>\n",
|
| 1224 |
+
" <tr>\n",
|
| 1225 |
+
" <th>53510</th>\n",
|
| 1226 |
+
" <td>14217127</td>\n",
|
| 1227 |
+
" <td>45276300</td>\n",
|
| 1228 |
+
" <td>Animalia</td>\n",
|
| 1229 |
+
" <td>Cnidaria</td>\n",
|
| 1230 |
+
" <td>Anthozoa</td>\n",
|
| 1231 |
+
" <td>Scleractinia</td>\n",
|
| 1232 |
+
" <td>Acroporidae</td>\n",
|
| 1233 |
+
" <td>Acropora</td>\n",
|
| 1234 |
+
" <td>millepora</td>\n",
|
| 1235 |
+
" <td>staghorn coral</td>\n",
|
| 1236 |
+
" <td>True</td>\n",
|
| 1237 |
+
" </tr>\n",
|
| 1238 |
+
" <tr>\n",
|
| 1239 |
+
" <th>95841</th>\n",
|
| 1240 |
+
" <td>28509006</td>\n",
|
| 1241 |
+
" <td>332461</td>\n",
|
| 1242 |
+
" <td>Animalia</td>\n",
|
| 1243 |
+
" <td>Chordata</td>\n",
|
| 1244 |
+
" <td>Amphibia</td>\n",
|
| 1245 |
+
" <td>Caudata</td>\n",
|
| 1246 |
+
" <td>Salamandridae</td>\n",
|
| 1247 |
+
" <td>Tylototriton</td>\n",
|
| 1248 |
+
" <td>verrucosus</td>\n",
|
| 1249 |
+
" <td>Yunnan Newt</td>\n",
|
| 1250 |
+
" <td>True</td>\n",
|
| 1251 |
+
" </tr>\n",
|
| 1252 |
+
" </tbody>\n",
|
| 1253 |
+
"</table>\n",
|
| 1254 |
+
"</div>"
|
| 1255 |
+
],
|
| 1256 |
+
"text/plain": [
|
| 1257 |
+
" eol_content_id eol_page_id kingdom phylum class \\\n",
|
| 1258 |
+
"53510 14217127 45276300 Animalia Cnidaria Anthozoa \n",
|
| 1259 |
+
"95841 28509006 332461 Animalia Chordata Amphibia \n",
|
| 1260 |
+
"\n",
|
| 1261 |
+
" order family genus species common \\\n",
|
| 1262 |
+
"53510 Scleractinia Acroporidae Acropora millepora staghorn coral \n",
|
| 1263 |
+
"95841 Caudata Salamandridae Tylototriton verrucosus Yunnan Newt \n",
|
| 1264 |
+
"\n",
|
| 1265 |
+
" duplicate_common \n",
|
| 1266 |
+
"53510 True \n",
|
| 1267 |
+
"95841 True "
|
| 1268 |
+
]
|
| 1269 |
+
},
|
| 1270 |
+
"execution_count": 9,
|
| 1271 |
+
"metadata": {},
|
| 1272 |
+
"output_type": "execute_result"
|
| 1273 |
+
}
|
| 1274 |
+
],
|
| 1275 |
+
"source": [
|
| 1276 |
+
"rs_pred[\"duplicate_page\"] = rs_pred.duplicated(\"eol_page_id\", keep = \"first\")\n",
|
| 1277 |
+
"single_page = rs_pred.loc[~rs_pred[\"duplicate_page\"]]\n",
|
| 1278 |
+
"single_page = single_page[cols_interest]\n",
|
| 1279 |
+
"single_page[\"duplicate_common\"] = rs_pred.duplicated(\"common\", keep = \"first\")\n",
|
| 1280 |
+
"\n",
|
| 1281 |
+
"single_page.loc[single_page[\"duplicate_common\"]]"
|
| 1282 |
+
]
|
| 1283 |
+
},
|
| 1284 |
+
{
|
| 1285 |
+
"cell_type": "code",
|
| 1286 |
+
"execution_count": 10,
|
| 1287 |
+
"metadata": {},
|
| 1288 |
+
"outputs": [
|
| 1289 |
+
{
|
| 1290 |
+
"data": {
|
| 1291 |
+
"text/plain": [
|
| 1292 |
+
"(400, 11)"
|
| 1293 |
+
]
|
| 1294 |
+
},
|
| 1295 |
+
"execution_count": 10,
|
| 1296 |
+
"metadata": {},
|
| 1297 |
+
"output_type": "execute_result"
|
| 1298 |
+
}
|
| 1299 |
+
],
|
| 1300 |
+
"source": [
|
| 1301 |
+
"single_page.shape"
|
| 1302 |
+
]
|
| 1303 |
+
},
|
| 1304 |
+
{
|
| 1305 |
+
"cell_type": "code",
|
| 1306 |
+
"execution_count": 11,
|
| 1307 |
+
"metadata": {},
|
| 1308 |
+
"outputs": [
|
| 1309 |
+
{
|
| 1310 |
+
"data": {
|
| 1311 |
+
"text/html": [
|
| 1312 |
+
"<div>\n",
|
| 1313 |
+
"<style scoped>\n",
|
| 1314 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1315 |
+
" vertical-align: middle;\n",
|
| 1316 |
+
" }\n",
|
| 1317 |
+
"\n",
|
| 1318 |
+
" .dataframe tbody tr th {\n",
|
| 1319 |
+
" vertical-align: top;\n",
|
| 1320 |
+
" }\n",
|
| 1321 |
+
"\n",
|
| 1322 |
+
" .dataframe thead th {\n",
|
| 1323 |
+
" text-align: right;\n",
|
| 1324 |
+
" }\n",
|
| 1325 |
+
"</style>\n",
|
| 1326 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1327 |
+
" <thead>\n",
|
| 1328 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1329 |
+
" <th></th>\n",
|
| 1330 |
+
" <th>eol_content_id</th>\n",
|
| 1331 |
+
" <th>eol_page_id</th>\n",
|
| 1332 |
+
" <th>kingdom</th>\n",
|
| 1333 |
+
" <th>phylum</th>\n",
|
| 1334 |
+
" <th>class</th>\n",
|
| 1335 |
+
" <th>order</th>\n",
|
| 1336 |
+
" <th>family</th>\n",
|
| 1337 |
+
" <th>genus</th>\n",
|
| 1338 |
+
" <th>species</th>\n",
|
| 1339 |
+
" <th>common</th>\n",
|
| 1340 |
+
" <th>duplicate_common</th>\n",
|
| 1341 |
+
" </tr>\n",
|
| 1342 |
+
" </thead>\n",
|
| 1343 |
+
" <tbody>\n",
|
| 1344 |
+
" <tr>\n",
|
| 1345 |
+
" <th>5280</th>\n",
|
| 1346 |
+
" <td>28261341</td>\n",
|
| 1347 |
+
" <td>45276299</td>\n",
|
| 1348 |
+
" <td>Animalia</td>\n",
|
| 1349 |
+
" <td>Cnidaria</td>\n",
|
| 1350 |
+
" <td>Anthozoa</td>\n",
|
| 1351 |
+
" <td>Scleractinia</td>\n",
|
| 1352 |
+
" <td>Acroporidae</td>\n",
|
| 1353 |
+
" <td>Acropora</td>\n",
|
| 1354 |
+
" <td>acuminata</td>\n",
|
| 1355 |
+
" <td>staghorn coral</td>\n",
|
| 1356 |
+
" <td>False</td>\n",
|
| 1357 |
+
" </tr>\n",
|
| 1358 |
+
" <tr>\n",
|
| 1359 |
+
" <th>17074</th>\n",
|
| 1360 |
+
" <td>8777107</td>\n",
|
| 1361 |
+
" <td>331513</td>\n",
|
| 1362 |
+
" <td>Animalia</td>\n",
|
| 1363 |
+
" <td>Chordata</td>\n",
|
| 1364 |
+
" <td>Amphibia</td>\n",
|
| 1365 |
+
" <td>Caudata</td>\n",
|
| 1366 |
+
" <td>Salamandridae</td>\n",
|
| 1367 |
+
" <td>Tylototriton</td>\n",
|
| 1368 |
+
" <td>shanjing</td>\n",
|
| 1369 |
+
" <td>Yunnan Newt</td>\n",
|
| 1370 |
+
" <td>False</td>\n",
|
| 1371 |
+
" </tr>\n",
|
| 1372 |
+
" <tr>\n",
|
| 1373 |
+
" <th>53510</th>\n",
|
| 1374 |
+
" <td>14217127</td>\n",
|
| 1375 |
+
" <td>45276300</td>\n",
|
| 1376 |
+
" <td>Animalia</td>\n",
|
| 1377 |
+
" <td>Cnidaria</td>\n",
|
| 1378 |
+
" <td>Anthozoa</td>\n",
|
| 1379 |
+
" <td>Scleractinia</td>\n",
|
| 1380 |
+
" <td>Acroporidae</td>\n",
|
| 1381 |
+
" <td>Acropora</td>\n",
|
| 1382 |
+
" <td>millepora</td>\n",
|
| 1383 |
+
" <td>staghorn coral</td>\n",
|
| 1384 |
+
" <td>True</td>\n",
|
| 1385 |
+
" </tr>\n",
|
| 1386 |
+
" <tr>\n",
|
| 1387 |
+
" <th>95841</th>\n",
|
| 1388 |
+
" <td>28509006</td>\n",
|
| 1389 |
+
" <td>332461</td>\n",
|
| 1390 |
+
" <td>Animalia</td>\n",
|
| 1391 |
+
" <td>Chordata</td>\n",
|
| 1392 |
+
" <td>Amphibia</td>\n",
|
| 1393 |
+
" <td>Caudata</td>\n",
|
| 1394 |
+
" <td>Salamandridae</td>\n",
|
| 1395 |
+
" <td>Tylototriton</td>\n",
|
| 1396 |
+
" <td>verrucosus</td>\n",
|
| 1397 |
+
" <td>Yunnan Newt</td>\n",
|
| 1398 |
+
" <td>True</td>\n",
|
| 1399 |
+
" </tr>\n",
|
| 1400 |
+
" </tbody>\n",
|
| 1401 |
+
"</table>\n",
|
| 1402 |
+
"</div>"
|
| 1403 |
+
],
|
| 1404 |
+
"text/plain": [
|
| 1405 |
+
" eol_content_id eol_page_id kingdom phylum class \\\n",
|
| 1406 |
+
"5280 28261341 45276299 Animalia Cnidaria Anthozoa \n",
|
| 1407 |
+
"17074 8777107 331513 Animalia Chordata Amphibia \n",
|
| 1408 |
+
"53510 14217127 45276300 Animalia Cnidaria Anthozoa \n",
|
| 1409 |
+
"95841 28509006 332461 Animalia Chordata Amphibia \n",
|
| 1410 |
+
"\n",
|
| 1411 |
+
" order family genus species common \\\n",
|
| 1412 |
+
"5280 Scleractinia Acroporidae Acropora acuminata staghorn coral \n",
|
| 1413 |
+
"17074 Caudata Salamandridae Tylototriton shanjing Yunnan Newt \n",
|
| 1414 |
+
"53510 Scleractinia Acroporidae Acropora millepora staghorn coral \n",
|
| 1415 |
+
"95841 Caudata Salamandridae Tylototriton verrucosus Yunnan Newt \n",
|
| 1416 |
+
"\n",
|
| 1417 |
+
" duplicate_common \n",
|
| 1418 |
+
"5280 False \n",
|
| 1419 |
+
"17074 False \n",
|
| 1420 |
+
"53510 True \n",
|
| 1421 |
+
"95841 True "
|
| 1422 |
+
]
|
| 1423 |
+
},
|
| 1424 |
+
"execution_count": 11,
|
| 1425 |
+
"metadata": {},
|
| 1426 |
+
"output_type": "execute_result"
|
| 1427 |
+
}
|
| 1428 |
+
],
|
| 1429 |
+
"source": [
|
| 1430 |
+
"duplicated_common_names = [\"staghorn coral\", \"Yunnan Newt\"]\n",
|
| 1431 |
+
"single_page.loc[single_page[\"common\"].isin(duplicated_common_names)]"
|
| 1432 |
+
]
|
| 1433 |
+
},
|
| 1434 |
+
{
|
| 1435 |
+
"cell_type": "markdown",
|
| 1436 |
+
"metadata": {},
|
| 1437 |
+
"source": [
|
| 1438 |
+
"So we have two common names that are each used for two species (within the same genus). That's not terribly unusual, but good to know.\n",
|
| 1439 |
+
"\n",
|
| 1440 |
+
"### Add the Common Name Column"
|
| 1441 |
+
]
|
| 1442 |
+
},
|
| 1443 |
+
{
|
| 1444 |
+
"cell_type": "code",
|
| 1445 |
+
"execution_count": 14,
|
| 1446 |
+
"metadata": {},
|
| 1447 |
+
"outputs": [
|
| 1448 |
+
{
|
| 1449 |
+
"data": {
|
| 1450 |
+
"text/plain": [
|
| 1451 |
+
"rarespecies_id 11983\n",
|
| 1452 |
+
"eol_content_id 11983\n",
|
| 1453 |
+
"eol_page_id 400\n",
|
| 1454 |
+
"kingdom 1\n",
|
| 1455 |
+
"phylum 5\n",
|
| 1456 |
+
"class 15\n",
|
| 1457 |
+
"order 85\n",
|
| 1458 |
+
"family 202\n",
|
| 1459 |
+
"genus 316\n",
|
| 1460 |
+
"species 385\n",
|
| 1461 |
+
"sciName 400\n",
|
| 1462 |
+
"common 398\n",
|
| 1463 |
+
"dtype: int64"
|
| 1464 |
+
]
|
| 1465 |
+
},
|
| 1466 |
+
"execution_count": 14,
|
| 1467 |
+
"metadata": {},
|
| 1468 |
+
"output_type": "execute_result"
|
| 1469 |
+
}
|
| 1470 |
+
],
|
| 1471 |
+
"source": [
|
| 1472 |
+
"def get_common_name(page_id):\n",
|
| 1473 |
+
" return single_page.loc[single_page[\"eol_page_id\"] == page_id, \"common\"].values[0]\n",
|
| 1474 |
+
"\n",
|
| 1475 |
+
"updated_catalog[\"common\"] = updated_catalog[\"eol_page_id\"].apply(get_common_name)\n",
|
| 1476 |
+
"updated_catalog.nunique()"
|
| 1477 |
+
]
|
| 1478 |
+
},
|
| 1479 |
+
{
|
| 1480 |
+
"cell_type": "markdown",
|
| 1481 |
+
"metadata": {},
|
| 1482 |
+
"source": [
|
| 1483 |
+
"### Save Updated Version with Common Names"
|
| 1484 |
+
]
|
| 1485 |
+
},
|
| 1486 |
+
{
|
| 1487 |
+
"cell_type": "code",
|
| 1488 |
+
"execution_count": 15,
|
| 1489 |
+
"metadata": {},
|
| 1490 |
+
"outputs": [],
|
| 1491 |
+
"source": [
|
| 1492 |
+
"updated_catalog.to_csv(RS_FILEPATH + \"rarespecies-catalog.csv\", index = False)"
|
| 1493 |
+
]
|
| 1494 |
+
},
|
| 1495 |
{
|
| 1496 |
"cell_type": "code",
|
| 1497 |
"execution_count": null,
|
rare_species/data/rarespecies-catalog.csv
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:96c458bd580caf5df4743c639eb38490e62eddef44b92be519d6771bdc2bf8fa
|
| 3 |
+
size 1953805
|