egrace479 commited on
Commit
ca52b5d
·
1 Parent(s): 2b1d4ae

Updated count information to include all values that should show up as warnings when running check_taxa.

Browse files
data/tol_hierarchy_test.csv DELETED
The diff for this file is too large to render. See raw diff
 
notebooks/missing_taxa_testGen.ipynb CHANGED
@@ -18,7 +18,7 @@
18
  "name": "stderr",
19
  "output_type": "stream",
20
  "text": [
21
- "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_70089/3694103411.py:1: DtypeWarning: Columns (4,5,6) have mixed types. Specify dtype option on import or set low_memory=False.\n",
22
  " df = pd.read_csv(\"../data/v1-dev-names.csv\")\n"
23
  ]
24
  }
@@ -56,25 +56,25 @@
56
  "output_type": "stream",
57
  "text": [
58
  "<class 'pandas.core.frame.DataFrame'>\n",
59
- "Index: 1000 entries, 7986767 to 8659983\n",
60
  "Data columns (total 17 columns):\n",
61
  " # Column Non-Null Count Dtype \n",
62
  "--- ------ -------------- ----- \n",
63
  " 0 treeoflife_id 1000 non-null object \n",
64
- " 1 eol_content_id 655 non-null float64\n",
65
- " 2 eol_page_id 655 non-null float64\n",
66
- " 3 bioscan_part 93 non-null float64\n",
67
- " 4 bioscan_filename 93 non-null object \n",
68
- " 5 inat21_filename 252 non-null object \n",
69
- " 6 inat21_cls_name 252 non-null object \n",
70
- " 7 inat21_cls_num 252 non-null float64\n",
71
- " 8 kingdom 728 non-null object \n",
72
- " 9 phylum 728 non-null object \n",
73
- " 10 class 628 non-null object \n",
74
- " 11 order 726 non-null object \n",
75
- " 12 family 721 non-null object \n",
76
- " 13 genus 779 non-null object \n",
77
- " 14 species 685 non-null object \n",
78
  " 15 common 1000 non-null object \n",
79
  " 16 data_source 1000 non-null object \n",
80
  "dtypes: float64(4), object(13)\n",
@@ -83,7 +83,7 @@
83
  }
84
  ],
85
  "source": [
86
- "df_small = df.loc[df.data_source != 'iNat'].sample(1000)\n",
87
  "df_small.info(show_counts = True)"
88
  ]
89
  },
@@ -97,29 +97,29 @@
97
  "output_type": "stream",
98
  "text": [
99
  "<class 'pandas.core.frame.DataFrame'>\n",
100
- "Index: 779 entries, 7986767 to 8659983\n",
101
  "Data columns (total 17 columns):\n",
102
  " # Column Non-Null Count Dtype \n",
103
  "--- ------ -------------- ----- \n",
104
- " 0 treeoflife_id 779 non-null object \n",
105
- " 1 eol_content_id 506 non-null float64\n",
106
- " 2 eol_page_id 506 non-null float64\n",
107
- " 3 bioscan_part 21 non-null float64\n",
108
- " 4 bioscan_filename 21 non-null object \n",
109
- " 5 inat21_filename 252 non-null object \n",
110
- " 6 inat21_cls_name 252 non-null object \n",
111
- " 7 inat21_cls_num 252 non-null float64\n",
112
- " 8 kingdom 647 non-null object \n",
113
- " 9 phylum 647 non-null object \n",
114
- " 10 class 549 non-null object \n",
115
- " 11 order 645 non-null object \n",
116
- " 12 family 643 non-null object \n",
117
- " 13 genus 779 non-null object \n",
118
- " 14 species 684 non-null object \n",
119
- " 15 common 779 non-null object \n",
120
- " 16 data_source 779 non-null object \n",
121
  "dtypes: float64(4), object(13)\n",
122
- "memory usage: 109.5+ KB\n"
123
  ]
124
  }
125
  ],
@@ -171,7 +171,7 @@
171
  }
172
  ],
173
  "source": [
174
- "bio_eol = df.loc[df.data_source != 'iNat']\n",
175
  "null_genus = bio_eol.loc[bio_eol.genus.isna()]\n",
176
  "null_genus.info(show_counts = True)"
177
  ]
@@ -201,26 +201,26 @@
201
  },
202
  {
203
  "cell_type": "code",
204
- "execution_count": 9,
205
  "metadata": {},
206
  "outputs": [
207
  {
208
  "data": {
209
  "text/plain": [
210
- "10002735 caprata\n",
211
- "5642543 paradidyma malaise2555\n",
212
- "5208448 lapponicum\n",
213
- "1762361 irrorata\n",
214
- "556451 perplexus\n",
215
- "3296890 (unidentified)\n",
216
- "2533982 senegalia senegal\n",
217
- "9869450 punctinalis\n",
218
- "4220628 coriaria welw. ex oliv.\n",
219
- "7126430 micrantha\n",
220
  "Name: species, dtype: object"
221
  ]
222
  },
223
- "execution_count": 9,
224
  "metadata": {},
225
  "output_type": "execute_result"
226
  }
@@ -231,14 +231,14 @@
231
  },
232
  {
233
  "cell_type": "code",
234
- "execution_count": 10,
235
  "metadata": {},
236
  "outputs": [
237
  {
238
  "name": "stdout",
239
  "output_type": "stream",
240
  "text": [
241
- "161\n"
242
  ]
243
  }
244
  ],
@@ -254,28 +254,85 @@
254
  "cell_type": "markdown",
255
  "metadata": {},
256
  "source": [
257
- "Good, these are represented too, so we can save this file."
258
  ]
259
  },
260
  {
261
  "cell_type": "code",
262
- "execution_count": 11,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  "metadata": {},
264
  "outputs": [],
265
  "source": [
266
- "df_test.to_csv(\"../data/tol_hierarchy_test.csv\", index = False)"
267
  ]
268
  },
269
  {
270
  "cell_type": "markdown",
271
  "metadata": {},
272
  "source": [
273
- "There is also apparently a species which is labeled as `(unidentified)`. Let's check where that is and if there's more than one (in our full dataset)."
274
  ]
275
  },
276
  {
277
  "cell_type": "code",
278
- "execution_count": 12,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  "metadata": {},
280
  "outputs": [
281
  {
@@ -322,7 +379,7 @@
322
  },
323
  {
324
  "cell_type": "code",
325
- "execution_count": 13,
326
  "metadata": {},
327
  "outputs": [
328
  {
@@ -367,30 +424,10 @@
367
  " </thead>\n",
368
  " <tbody>\n",
369
  " <tr>\n",
370
- " <th>10369023</th>\n",
371
- " <td>b98a7e24-4848-4134-bad3-eedfce536fab</td>\n",
372
- " <td>14844649.0</td>\n",
373
- " <td>64430448.0</td>\n",
374
- " <td>NaN</td>\n",
375
- " <td>NaN</td>\n",
376
- " <td>NaN</td>\n",
377
- " <td>NaN</td>\n",
378
- " <td>NaN</td>\n",
379
- " <td>NaN</td>\n",
380
- " <td>NaN</td>\n",
381
- " <td>NaN</td>\n",
382
- " <td>NaN</td>\n",
383
- " <td>NaN</td>\n",
384
- " <td>Cis</td>\n",
385
- " <td>(unidentified)</td>\n",
386
- " <td>Cis (unidentified)</td>\n",
387
- " <td>EOL</td>\n",
388
- " </tr>\n",
389
- " <tr>\n",
390
- " <th>7268955</th>\n",
391
- " <td>228a79c2-a482-4cd4-9a56-a000c4780b68</td>\n",
392
- " <td>14842294.0</td>\n",
393
- " <td>64429582.0</td>\n",
394
  " <td>NaN</td>\n",
395
  " <td>NaN</td>\n",
396
  " <td>NaN</td>\n",
@@ -401,16 +438,16 @@
401
  " <td>NaN</td>\n",
402
  " <td>NaN</td>\n",
403
  " <td>NaN</td>\n",
404
- " <td>Sarcophaga</td>\n",
405
  " <td>(unidentified)</td>\n",
406
- " <td>Sarcophaga (unidentified)</td>\n",
407
  " <td>EOL</td>\n",
408
  " </tr>\n",
409
  " <tr>\n",
410
- " <th>1549482</th>\n",
411
- " <td>f81c2ce7-b2dc-4d13-8991-5a20907610bb</td>\n",
412
- " <td>14842814.0</td>\n",
413
- " <td>64432966.0</td>\n",
414
  " <td>NaN</td>\n",
415
  " <td>NaN</td>\n",
416
  " <td>NaN</td>\n",
@@ -421,16 +458,16 @@
421
  " <td>NaN</td>\n",
422
  " <td>NaN</td>\n",
423
  " <td>NaN</td>\n",
424
- " <td>Chromista</td>\n",
425
  " <td>(unidentified)</td>\n",
426
- " <td>Chromista (unidentified)</td>\n",
427
  " <td>EOL</td>\n",
428
  " </tr>\n",
429
  " <tr>\n",
430
- " <th>6552233</th>\n",
431
- " <td>724ac709-31ee-41df-b1b2-a4fbcda8a867</td>\n",
432
- " <td>14845112.0</td>\n",
433
- " <td>64430050.0</td>\n",
434
  " <td>NaN</td>\n",
435
  " <td>NaN</td>\n",
436
  " <td>NaN</td>\n",
@@ -441,16 +478,16 @@
441
  " <td>NaN</td>\n",
442
  " <td>NaN</td>\n",
443
  " <td>NaN</td>\n",
444
- " <td>Myrmica</td>\n",
445
  " <td>(unidentified)</td>\n",
446
- " <td>Myrmica (unidentified)</td>\n",
447
  " <td>EOL</td>\n",
448
  " </tr>\n",
449
  " <tr>\n",
450
- " <th>7064292</th>\n",
451
- " <td>079cac60-e040-4ae0-a587-d9a73b0bff65</td>\n",
452
- " <td>14851701.0</td>\n",
453
- " <td>64429842.0</td>\n",
454
  " <td>NaN</td>\n",
455
  " <td>NaN</td>\n",
456
  " <td>NaN</td>\n",
@@ -461,9 +498,9 @@
461
  " <td>NaN</td>\n",
462
  " <td>NaN</td>\n",
463
  " <td>NaN</td>\n",
464
- " <td>Phygadeuon</td>\n",
465
  " <td>(unidentified)</td>\n",
466
- " <td>Phygadeuon (unidentified)</td>\n",
467
  " <td>EOL</td>\n",
468
  " </tr>\n",
469
  " <tr>\n",
@@ -487,50 +524,10 @@
487
  " <td>EOL</td>\n",
488
  " </tr>\n",
489
  " <tr>\n",
490
- " <th>6605868</th>\n",
491
- " <td>9a4cf29a-06d5-4c1c-94dc-6f0486347755</td>\n",
492
- " <td>14843938.0</td>\n",
493
- " <td>64427784.0</td>\n",
494
- " <td>NaN</td>\n",
495
- " <td>NaN</td>\n",
496
- " <td>NaN</td>\n",
497
- " <td>NaN</td>\n",
498
- " <td>NaN</td>\n",
499
- " <td>NaN</td>\n",
500
- " <td>NaN</td>\n",
501
- " <td>NaN</td>\n",
502
- " <td>NaN</td>\n",
503
- " <td>NaN</td>\n",
504
- " <td>Entoloma</td>\n",
505
- " <td>(unidentified)</td>\n",
506
- " <td>Entoloma (unidentified)</td>\n",
507
- " <td>EOL</td>\n",
508
- " </tr>\n",
509
- " <tr>\n",
510
- " <th>1138925</th>\n",
511
- " <td>2b4c8067-3595-4d87-897e-9d3600e3a86f</td>\n",
512
- " <td>14842566.0</td>\n",
513
- " <td>64430882.0</td>\n",
514
- " <td>NaN</td>\n",
515
- " <td>NaN</td>\n",
516
- " <td>NaN</td>\n",
517
- " <td>NaN</td>\n",
518
- " <td>NaN</td>\n",
519
- " <td>NaN</td>\n",
520
- " <td>NaN</td>\n",
521
- " <td>NaN</td>\n",
522
- " <td>NaN</td>\n",
523
- " <td>NaN</td>\n",
524
- " <td>Hydropsyche</td>\n",
525
- " <td>(unidentified)</td>\n",
526
- " <td>Hydropsyche (unidentified)</td>\n",
527
- " <td>EOL</td>\n",
528
- " </tr>\n",
529
- " <tr>\n",
530
- " <th>2018314</th>\n",
531
- " <td>2726bcc0-5c18-401a-a0a0-ad4a2cb4e302</td>\n",
532
- " <td>14845986.0</td>\n",
533
- " <td>64426150.0</td>\n",
534
  " <td>NaN</td>\n",
535
  " <td>NaN</td>\n",
536
  " <td>NaN</td>\n",
@@ -541,16 +538,16 @@
541
  " <td>NaN</td>\n",
542
  " <td>NaN</td>\n",
543
  " <td>NaN</td>\n",
544
- " <td>Chlorophyta</td>\n",
545
  " <td>(unidentified)</td>\n",
546
- " <td>Chlorophyta (unidentified)</td>\n",
547
  " <td>EOL</td>\n",
548
  " </tr>\n",
549
  " <tr>\n",
550
- " <th>1675874</th>\n",
551
- " <td>578809ee-126c-468e-a39b-2878e1dafc21</td>\n",
552
- " <td>14845571.0</td>\n",
553
- " <td>64431544.0</td>\n",
554
  " <td>NaN</td>\n",
555
  " <td>NaN</td>\n",
556
  " <td>NaN</td>\n",
@@ -561,9 +558,9 @@
561
  " <td>NaN</td>\n",
562
  " <td>NaN</td>\n",
563
  " <td>NaN</td>\n",
564
- " <td>Porifera</td>\n",
565
  " <td>(unidentified)</td>\n",
566
- " <td>Porifera (unidentified)</td>\n",
567
  " <td>EOL</td>\n",
568
  " </tr>\n",
569
  " </tbody>\n",
@@ -571,62 +568,50 @@
571
  "</div>"
572
  ],
573
  "text/plain": [
574
- " treeoflife_id eol_content_id eol_page_id \n",
575
- "10369023 b98a7e24-4848-4134-bad3-eedfce536fab 14844649.0 64430448.0 \\\n",
576
- "7268955 228a79c2-a482-4cd4-9a56-a000c4780b68 14842294.0 64429582.0 \n",
577
- "1549482 f81c2ce7-b2dc-4d13-8991-5a20907610bb 14842814.0 64432966.0 \n",
578
- "6552233 724ac709-31ee-41df-b1b2-a4fbcda8a867 14845112.0 64430050.0 \n",
579
- "7064292 079cac60-e040-4ae0-a587-d9a73b0bff65 14851701.0 64429842.0 \n",
580
- "972647 01633bbe-44f9-4e8d-b4db-d2d9678906eb 14845039.0 64429476.0 \n",
581
- "6605868 9a4cf29a-06d5-4c1c-94dc-6f0486347755 14843938.0 64427784.0 \n",
582
- "1138925 2b4c8067-3595-4d87-897e-9d3600e3a86f 14842566.0 64430882.0 \n",
583
- "2018314 2726bcc0-5c18-401a-a0a0-ad4a2cb4e302 14845986.0 64426150.0 \n",
584
- "1675874 578809ee-126c-468e-a39b-2878e1dafc21 14845571.0 64431544.0 \n",
585
  "\n",
586
- " bioscan_part bioscan_filename inat21_filename inat21_cls_name \n",
587
- "10369023 NaN NaN NaN NaN \\\n",
588
- "7268955 NaN NaN NaN NaN \n",
589
- "1549482 NaN NaN NaN NaN \n",
590
- "6552233 NaN NaN NaN NaN \n",
591
- "7064292 NaN NaN NaN NaN \n",
592
- "972647 NaN NaN NaN NaN \n",
593
- "6605868 NaN NaN NaN NaN \n",
594
- "1138925 NaN NaN NaN NaN \n",
595
- "2018314 NaN NaN NaN NaN \n",
596
- "1675874 NaN NaN NaN NaN \n",
597
  "\n",
598
- " inat21_cls_num kingdom phylum class order family genus \n",
599
- "10369023 NaN NaN NaN NaN NaN NaN Cis \\\n",
600
- "7268955 NaN NaN NaN NaN NaN NaN Sarcophaga \n",
601
- "1549482 NaN NaN NaN NaN NaN NaN Chromista \n",
602
- "6552233 NaN NaN NaN NaN NaN NaN Myrmica \n",
603
- "7064292 NaN NaN NaN NaN NaN NaN Phygadeuon \n",
604
- "972647 NaN NaN NaN NaN NaN NaN Cheilosia \n",
605
- "6605868 NaN NaN NaN NaN NaN NaN Entoloma \n",
606
- "1138925 NaN NaN NaN NaN NaN NaN Hydropsyche \n",
607
- "2018314 NaN NaN NaN NaN NaN NaN Chlorophyta \n",
608
- "1675874 NaN NaN NaN NaN NaN NaN Porifera \n",
609
  "\n",
610
- " species common data_source \n",
611
- "10369023 (unidentified) Cis (unidentified) EOL \n",
612
- "7268955 (unidentified) Sarcophaga (unidentified) EOL \n",
613
- "1549482 (unidentified) Chromista (unidentified) EOL \n",
614
- "6552233 (unidentified) Myrmica (unidentified) EOL \n",
615
- "7064292 (unidentified) Phygadeuon (unidentified) EOL \n",
616
- "972647 (unidentified) Cheilosia (unidentified) EOL \n",
617
- "6605868 (unidentified) Entoloma (unidentified) EOL \n",
618
- "1138925 (unidentified) Hydropsyche (unidentified) EOL \n",
619
- "2018314 (unidentified) Chlorophyta (unidentified) EOL \n",
620
- "1675874 (unidentified) Porifera (unidentified) EOL "
621
  ]
622
  },
623
- "execution_count": 13,
624
  "metadata": {},
625
  "output_type": "execute_result"
626
  }
627
  ],
628
  "source": [
629
- "df.loc[df.species == \"(unidentified)\"].sample(10)"
630
  ]
631
  },
632
  {
@@ -680,19 +665,19 @@
680
  "output_type": "stream",
681
  "text": [
682
  "<class 'pandas.core.frame.DataFrame'>\n",
683
- "Index: 779 entries, 7986767 to 8659983\n",
684
  "Data columns (total 7 columns):\n",
685
  " # Column Non-Null Count Dtype \n",
686
  "--- ------ -------------- ----- \n",
687
- " 0 kingdom 647 non-null object\n",
688
- " 1 phylum 647 non-null object\n",
689
- " 2 class 549 non-null object\n",
690
- " 3 order 645 non-null object\n",
691
- " 4 family 643 non-null object\n",
692
- " 5 genus 779 non-null object\n",
693
- " 6 species 684 non-null object\n",
694
  "dtypes: object(7)\n",
695
- "memory usage: 48.7+ KB\n"
696
  ]
697
  }
698
  ],
@@ -705,23 +690,23 @@
705
  "metadata": {},
706
  "source": [
707
  "We should have\n",
708
- " - 132 missing `kingdom` and `phylum`\n",
709
- " - 230 missing `class`\n",
710
- " - 134 missing `family`"
711
  ]
712
  },
713
  {
714
  "cell_type": "code",
715
- "execution_count": 19,
716
  "metadata": {},
717
  "outputs": [
718
  {
719
  "data": {
720
  "text/plain": [
721
- "101"
722
  ]
723
  },
724
- "execution_count": 19,
725
  "metadata": {},
726
  "output_type": "execute_result"
727
  }
@@ -734,12 +719,12 @@
734
  "cell_type": "markdown",
735
  "metadata": {},
736
  "source": [
737
- "101 entries for which `species` is non-null, but `genus` is missing."
738
  ]
739
  },
740
  {
741
  "cell_type": "code",
742
- "execution_count": 20,
743
  "metadata": {},
744
  "outputs": [],
745
  "source": [
@@ -748,7 +733,7 @@
748
  },
749
  {
750
  "cell_type": "code",
751
- "execution_count": 21,
752
  "metadata": {},
753
  "outputs": [
754
  {
@@ -756,19 +741,19 @@
756
  "output_type": "stream",
757
  "text": [
758
  "<class 'pandas.core.frame.DataFrame'>\n",
759
- "Index: 143 entries, 4772452 to 3877527\n",
760
  "Data columns (total 7 columns):\n",
761
  " # Column Non-Null Count Dtype \n",
762
  "--- ------ -------------- ----- \n",
763
- " 0 kingdom 3 non-null object\n",
764
- " 1 phylum 3 non-null object\n",
765
- " 2 class 3 non-null object\n",
766
- " 3 order 3 non-null object\n",
767
  " 4 family 0 non-null object\n",
768
  " 5 genus 0 non-null object\n",
769
  " 6 species 0 non-null object\n",
770
  "dtypes: object(7)\n",
771
- "memory usage: 8.9+ KB\n"
772
  ]
773
  }
774
  ],
@@ -780,12 +765,12 @@
780
  "cell_type": "markdown",
781
  "metadata": {},
782
  "source": [
783
- "Only 3 instances where `family` is null and higher order taxa are not."
784
  ]
785
  },
786
  {
787
  "cell_type": "code",
788
- "execution_count": 22,
789
  "metadata": {},
790
  "outputs": [
791
  {
@@ -793,19 +778,19 @@
793
  "output_type": "stream",
794
  "text": [
795
  "<class 'pandas.core.frame.DataFrame'>\n",
796
- "Index: 178 entries, 4943756 to 1467368\n",
797
  "Data columns (total 7 columns):\n",
798
  " # Column Non-Null Count Dtype \n",
799
  "--- ------ -------------- ----- \n",
800
- " 0 kingdom 178 non-null object\n",
801
- " 1 phylum 178 non-null object\n",
802
- " 2 class 141 non-null object\n",
803
- " 3 order 178 non-null object\n",
804
- " 4 family 178 non-null object\n",
805
  " 5 genus 0 non-null object\n",
806
- " 6 species 101 non-null object\n",
807
  "dtypes: object(7)\n",
808
- "memory usage: 11.1+ KB\n"
809
  ]
810
  }
811
  ],
@@ -817,7 +802,7 @@
817
  "cell_type": "markdown",
818
  "metadata": {},
819
  "source": [
820
- "For `family`, there should be a warning that 37 `class` values are not indicated."
821
  ]
822
  },
823
  {
@@ -829,7 +814,7 @@
829
  },
830
  {
831
  "cell_type": "code",
832
- "execution_count": 23,
833
  "metadata": {},
834
  "outputs": [
835
  {
@@ -837,19 +822,19 @@
837
  "output_type": "stream",
838
  "text": [
839
  "<class 'pandas.core.frame.DataFrame'>\n",
840
- "Index: 101 entries, 10434700 to 1467368\n",
841
  "Data columns (total 7 columns):\n",
842
  " # Column Non-Null Count Dtype \n",
843
  "--- ------ -------------- ----- \n",
844
- " 0 kingdom 101 non-null object\n",
845
- " 1 phylum 101 non-null object\n",
846
- " 2 class 65 non-null object\n",
847
- " 3 order 101 non-null object\n",
848
- " 4 family 101 non-null object\n",
849
  " 5 genus 0 non-null object\n",
850
- " 6 species 101 non-null object\n",
851
  "dtypes: object(7)\n",
852
- "memory usage: 6.3+ KB\n"
853
  ]
854
  }
855
  ],
@@ -863,12 +848,85 @@
863
  "source": [
864
  "We should have\n",
865
  " - no instances of missing `kingdom`, `phylum`, `order`, or `family` \n",
866
- " - 36 instances of missing `class`"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
867
  ]
868
  },
869
  {
870
  "cell_type": "markdown",
871
  "metadata": {},
 
 
 
 
 
 
 
 
 
872
  "source": []
873
  }
874
  ],
 
18
  "name": "stderr",
19
  "output_type": "stream",
20
  "text": [
21
+ "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_83240/3694103411.py:1: DtypeWarning: Columns (4,5,6) have mixed types. Specify dtype option on import or set low_memory=False.\n",
22
  " df = pd.read_csv(\"../data/v1-dev-names.csv\")\n"
23
  ]
24
  }
 
56
  "output_type": "stream",
57
  "text": [
58
  "<class 'pandas.core.frame.DataFrame'>\n",
59
+ "Index: 1000 entries, 1098219 to 6735833\n",
60
  "Data columns (total 17 columns):\n",
61
  " # Column Non-Null Count Dtype \n",
62
  "--- ------ -------------- ----- \n",
63
  " 0 treeoflife_id 1000 non-null object \n",
64
+ " 1 eol_content_id 860 non-null float64\n",
65
+ " 2 eol_page_id 860 non-null float64\n",
66
+ " 3 bioscan_part 140 non-null float64\n",
67
+ " 4 bioscan_filename 140 non-null object \n",
68
+ " 5 inat21_filename 0 non-null object \n",
69
+ " 6 inat21_cls_name 0 non-null object \n",
70
+ " 7 inat21_cls_num 0 non-null float64\n",
71
+ " 8 kingdom 633 non-null object \n",
72
+ " 9 phylum 633 non-null object \n",
73
+ " 10 class 499 non-null object \n",
74
+ " 11 order 626 non-null object \n",
75
+ " 12 family 632 non-null object \n",
76
+ " 13 genus 668 non-null object \n",
77
+ " 14 species 544 non-null object \n",
78
  " 15 common 1000 non-null object \n",
79
  " 16 data_source 1000 non-null object \n",
80
  "dtypes: float64(4), object(13)\n",
 
83
  }
84
  ],
85
  "source": [
86
+ "df_small = df.loc[df.data_source != 'iNat21'].sample(1000)\n",
87
  "df_small.info(show_counts = True)"
88
  ]
89
  },
 
97
  "output_type": "stream",
98
  "text": [
99
  "<class 'pandas.core.frame.DataFrame'>\n",
100
+ "Index: 668 entries, 3494190 to 4498346\n",
101
  "Data columns (total 17 columns):\n",
102
  " # Column Non-Null Count Dtype \n",
103
  "--- ------ -------------- ----- \n",
104
+ " 0 treeoflife_id 668 non-null object \n",
105
+ " 1 eol_content_id 646 non-null float64\n",
106
+ " 2 eol_page_id 646 non-null float64\n",
107
+ " 3 bioscan_part 22 non-null float64\n",
108
+ " 4 bioscan_filename 22 non-null object \n",
109
+ " 5 inat21_filename 0 non-null object \n",
110
+ " 6 inat21_cls_name 0 non-null object \n",
111
+ " 7 inat21_cls_num 0 non-null float64\n",
112
+ " 8 kingdom 498 non-null object \n",
113
+ " 9 phylum 498 non-null object \n",
114
+ " 10 class 365 non-null object \n",
115
+ " 11 order 491 non-null object \n",
116
+ " 12 family 498 non-null object \n",
117
+ " 13 genus 668 non-null object \n",
118
+ " 14 species 544 non-null object \n",
119
+ " 15 common 668 non-null object \n",
120
+ " 16 data_source 668 non-null object \n",
121
  "dtypes: float64(4), object(13)\n",
122
+ "memory usage: 93.9+ KB\n"
123
  ]
124
  }
125
  ],
 
171
  }
172
  ],
173
  "source": [
174
+ "bio_eol = df.loc[df.data_source != 'iNat21']\n",
175
  "null_genus = bio_eol.loc[bio_eol.genus.isna()]\n",
176
  "null_genus.info(show_counts = True)"
177
  ]
 
201
  },
202
  {
203
  "cell_type": "code",
204
+ "execution_count": 8,
205
  "metadata": {},
206
  "outputs": [
207
  {
208
  "data": {
209
  "text/plain": [
210
+ "5862285 cochleariifolia\n",
211
+ "3874515 oligosperma\n",
212
+ "4210027 polioptila caerulea\n",
213
+ "1482223 stigmaticus stigmaticus\n",
214
+ "2165326 umbellatum\n",
215
+ "6966418 contractus\n",
216
+ "4224046 marginatus\n",
217
+ "10349676 salpinctes obsoletus\n",
218
+ "6994793 bimaculata\n",
219
+ "4775194 olivaris\n",
220
  "Name: species, dtype: object"
221
  ]
222
  },
223
+ "execution_count": 8,
224
  "metadata": {},
225
  "output_type": "execute_result"
226
  }
 
231
  },
232
  {
233
  "cell_type": "code",
234
+ "execution_count": 9,
235
  "metadata": {},
236
  "outputs": [
237
  {
238
  "name": "stdout",
239
  "output_type": "stream",
240
  "text": [
241
+ "180\n"
242
  ]
243
  }
244
  ],
 
254
  "cell_type": "markdown",
255
  "metadata": {},
256
  "source": [
257
+ "Check `(unidentified)` is represented in our sample (see note below)."
258
  ]
259
  },
260
  {
261
  "cell_type": "code",
262
+ "execution_count": 10,
263
+ "metadata": {},
264
+ "outputs": [
265
+ {
266
+ "name": "stdout",
267
+ "output_type": "stream",
268
+ "text": [
269
+ "<class 'pandas.core.frame.DataFrame'>\n",
270
+ "Index: 0 entries\n",
271
+ "Data columns (total 17 columns):\n",
272
+ " # Column Non-Null Count Dtype \n",
273
+ "--- ------ -------------- ----- \n",
274
+ " 0 treeoflife_id 0 non-null object \n",
275
+ " 1 eol_content_id 0 non-null float64\n",
276
+ " 2 eol_page_id 0 non-null float64\n",
277
+ " 3 bioscan_part 0 non-null float64\n",
278
+ " 4 bioscan_filename 0 non-null object \n",
279
+ " 5 inat21_filename 0 non-null object \n",
280
+ " 6 inat21_cls_name 0 non-null object \n",
281
+ " 7 inat21_cls_num 0 non-null float64\n",
282
+ " 8 kingdom 0 non-null object \n",
283
+ " 9 phylum 0 non-null object \n",
284
+ " 10 class 0 non-null object \n",
285
+ " 11 order 0 non-null object \n",
286
+ " 12 family 0 non-null object \n",
287
+ " 13 genus 0 non-null object \n",
288
+ " 14 species 0 non-null object \n",
289
+ " 15 common 0 non-null object \n",
290
+ " 16 data_source 0 non-null object \n",
291
+ "dtypes: float64(4), object(13)\n",
292
+ "memory usage: 0.0+ bytes\n"
293
+ ]
294
+ }
295
+ ],
296
+ "source": [
297
+ "df_test.loc[df_test.species == \"(unidentified)\"].info(show_counts = True)"
298
+ ]
299
+ },
300
+ {
301
+ "cell_type": "code",
302
+ "execution_count": 12,
303
  "metadata": {},
304
  "outputs": [],
305
  "source": [
306
+ "df_test = pd.concat([df_test, df.loc[df.species == \"(unidentified)\"].sample(10)])"
307
  ]
308
  },
309
  {
310
  "cell_type": "markdown",
311
  "metadata": {},
312
  "source": [
313
+ "Good, these are now represented too, so we can save this file."
314
  ]
315
  },
316
  {
317
  "cell_type": "code",
318
+ "execution_count": 13,
319
+ "metadata": {},
320
+ "outputs": [],
321
+ "source": [
322
+ "# Don't overwrite current test set (but is in VC)\n",
323
+ "#df_test.to_csv(\"../data/tol_hierarchy_test.csv\", index = False)"
324
+ ]
325
+ },
326
+ {
327
+ "cell_type": "markdown",
328
+ "metadata": {},
329
+ "source": [
330
+ "There is also apparently a species which is labeled as `(unidentified)` (found in earlier run). Let's check where that is and if there's more than one (in our full dataset)."
331
+ ]
332
+ },
333
+ {
334
+ "cell_type": "code",
335
+ "execution_count": 11,
336
  "metadata": {},
337
  "outputs": [
338
  {
 
379
  },
380
  {
381
  "cell_type": "code",
382
+ "execution_count": 12,
383
  "metadata": {},
384
  "outputs": [
385
  {
 
424
  " </thead>\n",
425
  " <tbody>\n",
426
  " <tr>\n",
427
+ " <th>708128</th>\n",
428
+ " <td>d8ec4f3a-9f7d-45f8-af94-a9e6bc243d3b</td>\n",
429
+ " <td>14845132.0</td>\n",
430
+ " <td>64427694.0</td>\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  " <td>NaN</td>\n",
432
  " <td>NaN</td>\n",
433
  " <td>NaN</td>\n",
 
438
  " <td>NaN</td>\n",
439
  " <td>NaN</td>\n",
440
  " <td>NaN</td>\n",
441
+ " <td>Ascomycota</td>\n",
442
  " <td>(unidentified)</td>\n",
443
+ " <td>Ascomycota (unidentified)</td>\n",
444
  " <td>EOL</td>\n",
445
  " </tr>\n",
446
  " <tr>\n",
447
+ " <th>1746638</th>\n",
448
+ " <td>ae9457b9-9f7f-404a-87b8-0c69b2082a54</td>\n",
449
+ " <td>14844829.0</td>\n",
450
+ " <td>64428954.0</td>\n",
451
  " <td>NaN</td>\n",
452
  " <td>NaN</td>\n",
453
  " <td>NaN</td>\n",
 
458
  " <td>NaN</td>\n",
459
  " <td>NaN</td>\n",
460
  " <td>NaN</td>\n",
461
+ " <td>Noctuidae</td>\n",
462
  " <td>(unidentified)</td>\n",
463
+ " <td>Noctuidae (unidentified)</td>\n",
464
  " <td>EOL</td>\n",
465
  " </tr>\n",
466
  " <tr>\n",
467
+ " <th>74672</th>\n",
468
+ " <td>d00a6cdd-3ac4-4eca-98dc-8fe03c006dab</td>\n",
469
+ " <td>14845091.0</td>\n",
470
+ " <td>64429560.0</td>\n",
471
  " <td>NaN</td>\n",
472
  " <td>NaN</td>\n",
473
  " <td>NaN</td>\n",
 
478
  " <td>NaN</td>\n",
479
  " <td>NaN</td>\n",
480
  " <td>NaN</td>\n",
481
+ " <td>Limonia</td>\n",
482
  " <td>(unidentified)</td>\n",
483
+ " <td>Limonia (unidentified)</td>\n",
484
  " <td>EOL</td>\n",
485
  " </tr>\n",
486
  " <tr>\n",
487
+ " <th>7041469</th>\n",
488
+ " <td>3c02258d-c93d-400c-846e-d63c1064aa55</td>\n",
489
+ " <td>14843807.0</td>\n",
490
+ " <td>64430930.0</td>\n",
491
  " <td>NaN</td>\n",
492
  " <td>NaN</td>\n",
493
  " <td>NaN</td>\n",
 
498
  " <td>NaN</td>\n",
499
  " <td>NaN</td>\n",
500
  " <td>NaN</td>\n",
501
+ " <td>Panorpa</td>\n",
502
  " <td>(unidentified)</td>\n",
503
+ " <td>Panorpa (unidentified)</td>\n",
504
  " <td>EOL</td>\n",
505
  " </tr>\n",
506
  " <tr>\n",
 
524
  " <td>EOL</td>\n",
525
  " </tr>\n",
526
  " <tr>\n",
527
+ " <th>1462517</th>\n",
528
+ " <td>5ac64348-e45f-4c54-8316-379543ea1ab2</td>\n",
529
+ " <td>14845057.0</td>\n",
530
+ " <td>64427448.0</td>\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
531
  " <td>NaN</td>\n",
532
  " <td>NaN</td>\n",
533
  " <td>NaN</td>\n",
 
538
  " <td>NaN</td>\n",
539
  " <td>NaN</td>\n",
540
  " <td>NaN</td>\n",
541
+ " <td>Amerosporium</td>\n",
542
  " <td>(unidentified)</td>\n",
543
+ " <td>Amerosporium (unidentified)</td>\n",
544
  " <td>EOL</td>\n",
545
  " </tr>\n",
546
  " <tr>\n",
547
+ " <th>4604554</th>\n",
548
+ " <td>5b222d55-b57d-4b3e-bbdc-837fce856b0a</td>\n",
549
+ " <td>14844676.0</td>\n",
550
+ " <td>64430148.0</td>\n",
551
  " <td>NaN</td>\n",
552
  " <td>NaN</td>\n",
553
  " <td>NaN</td>\n",
 
558
  " <td>NaN</td>\n",
559
  " <td>NaN</td>\n",
560
  " <td>NaN</td>\n",
561
+ " <td>Symphyta</td>\n",
562
  " <td>(unidentified)</td>\n",
563
+ " <td>Symphyta (unidentified)</td>\n",
564
  " <td>EOL</td>\n",
565
  " </tr>\n",
566
  " </tbody>\n",
 
568
  "</div>"
569
  ],
570
  "text/plain": [
571
+ " treeoflife_id eol_content_id eol_page_id \n",
572
+ "708128 d8ec4f3a-9f7d-45f8-af94-a9e6bc243d3b 14845132.0 64427694.0 \\\n",
573
+ "1746638 ae9457b9-9f7f-404a-87b8-0c69b2082a54 14844829.0 64428954.0 \n",
574
+ "74672 d00a6cdd-3ac4-4eca-98dc-8fe03c006dab 14845091.0 64429560.0 \n",
575
+ "7041469 3c02258d-c93d-400c-846e-d63c1064aa55 14843807.0 64430930.0 \n",
576
+ "972647 01633bbe-44f9-4e8d-b4db-d2d9678906eb 14845039.0 64429476.0 \n",
577
+ "1462517 5ac64348-e45f-4c54-8316-379543ea1ab2 14845057.0 64427448.0 \n",
578
+ "4604554 5b222d55-b57d-4b3e-bbdc-837fce856b0a 14844676.0 64430148.0 \n",
 
 
 
579
  "\n",
580
+ " bioscan_part bioscan_filename inat21_filename inat21_cls_name \n",
581
+ "708128 NaN NaN NaN NaN \\\n",
582
+ "1746638 NaN NaN NaN NaN \n",
583
+ "74672 NaN NaN NaN NaN \n",
584
+ "7041469 NaN NaN NaN NaN \n",
585
+ "972647 NaN NaN NaN NaN \n",
586
+ "1462517 NaN NaN NaN NaN \n",
587
+ "4604554 NaN NaN NaN NaN \n",
 
 
 
588
  "\n",
589
+ " inat21_cls_num kingdom phylum class order family genus \n",
590
+ "708128 NaN NaN NaN NaN NaN NaN Ascomycota \\\n",
591
+ "1746638 NaN NaN NaN NaN NaN NaN Noctuidae \n",
592
+ "74672 NaN NaN NaN NaN NaN NaN Limonia \n",
593
+ "7041469 NaN NaN NaN NaN NaN NaN Panorpa \n",
594
+ "972647 NaN NaN NaN NaN NaN NaN Cheilosia \n",
595
+ "1462517 NaN NaN NaN NaN NaN NaN Amerosporium \n",
596
+ "4604554 NaN NaN NaN NaN NaN NaN Symphyta \n",
 
 
 
597
  "\n",
598
+ " species common data_source \n",
599
+ "708128 (unidentified) Ascomycota (unidentified) EOL \n",
600
+ "1746638 (unidentified) Noctuidae (unidentified) EOL \n",
601
+ "74672 (unidentified) Limonia (unidentified) EOL \n",
602
+ "7041469 (unidentified) Panorpa (unidentified) EOL \n",
603
+ "972647 (unidentified) Cheilosia (unidentified) EOL \n",
604
+ "1462517 (unidentified) Amerosporium (unidentified) EOL \n",
605
+ "4604554 (unidentified) Symphyta (unidentified) EOL "
 
 
 
606
  ]
607
  },
608
+ "execution_count": 12,
609
  "metadata": {},
610
  "output_type": "execute_result"
611
  }
612
  ],
613
  "source": [
614
+ "df.loc[df.species == \"(unidentified)\"].sample(7)"
615
  ]
616
  },
617
  {
 
665
  "output_type": "stream",
666
  "text": [
667
  "<class 'pandas.core.frame.DataFrame'>\n",
668
+ "Index: 678 entries, 3494190 to 2887231\n",
669
  "Data columns (total 7 columns):\n",
670
  " # Column Non-Null Count Dtype \n",
671
  "--- ------ -------------- ----- \n",
672
+ " 0 kingdom 498 non-null object\n",
673
+ " 1 phylum 498 non-null object\n",
674
+ " 2 class 365 non-null object\n",
675
+ " 3 order 491 non-null object\n",
676
+ " 4 family 498 non-null object\n",
677
+ " 5 genus 678 non-null object\n",
678
+ " 6 species 554 non-null object\n",
679
  "dtypes: object(7)\n",
680
+ "memory usage: 42.4+ KB\n"
681
  ]
682
  }
683
  ],
 
690
  "metadata": {},
691
  "source": [
692
  "We should have\n",
693
+ " - 180 missing `kingdom`, `phylum`, and `family` -- These numbers will not always be the same\n",
694
+ " - 313 missing `class`\n",
695
+ " - 187 missing `order`"
696
  ]
697
  },
698
  {
699
  "cell_type": "code",
700
+ "execution_count": 17,
701
  "metadata": {},
702
  "outputs": [
703
  {
704
  "data": {
705
  "text/plain": [
706
+ "100"
707
  ]
708
  },
709
+ "execution_count": 17,
710
  "metadata": {},
711
  "output_type": "execute_result"
712
  }
 
719
  "cell_type": "markdown",
720
  "metadata": {},
721
  "source": [
722
+ "100 entries for which `species` is non-null, but `genus` is missing."
723
  ]
724
  },
725
  {
726
  "cell_type": "code",
727
+ "execution_count": 18,
728
  "metadata": {},
729
  "outputs": [],
730
  "source": [
 
733
  },
734
  {
735
  "cell_type": "code",
736
+ "execution_count": 19,
737
  "metadata": {},
738
  "outputs": [
739
  {
 
741
  "output_type": "stream",
742
  "text": [
743
  "<class 'pandas.core.frame.DataFrame'>\n",
744
+ "Index: 198 entries, 1098219 to 1167968\n",
745
  "Data columns (total 7 columns):\n",
746
  " # Column Non-Null Count Dtype \n",
747
  "--- ------ -------------- ----- \n",
748
+ " 0 kingdom 1 non-null object\n",
749
+ " 1 phylum 1 non-null object\n",
750
+ " 2 class 1 non-null object\n",
751
+ " 3 order 1 non-null object\n",
752
  " 4 family 0 non-null object\n",
753
  " 5 genus 0 non-null object\n",
754
  " 6 species 0 non-null object\n",
755
  "dtypes: object(7)\n",
756
+ "memory usage: 12.4+ KB\n"
757
  ]
758
  }
759
  ],
 
765
  "cell_type": "markdown",
766
  "metadata": {},
767
  "source": [
768
+ "Only 1 instance where `family` is null and higher order taxa are not."
769
  ]
770
  },
771
  {
772
  "cell_type": "code",
773
+ "execution_count": 20,
774
  "metadata": {},
775
  "outputs": [
776
  {
 
778
  "output_type": "stream",
779
  "text": [
780
  "<class 'pandas.core.frame.DataFrame'>\n",
781
+ "Index: 234 entries, 157009 to 5416459\n",
782
  "Data columns (total 7 columns):\n",
783
  " # Column Non-Null Count Dtype \n",
784
  "--- ------ -------------- ----- \n",
785
+ " 0 kingdom 234 non-null object\n",
786
+ " 1 phylum 234 non-null object\n",
787
+ " 2 class 206 non-null object\n",
788
+ " 3 order 234 non-null object\n",
789
+ " 4 family 234 non-null object\n",
790
  " 5 genus 0 non-null object\n",
791
+ " 6 species 100 non-null object\n",
792
  "dtypes: object(7)\n",
793
+ "memory usage: 14.6+ KB\n"
794
  ]
795
  }
796
  ],
 
802
  "cell_type": "markdown",
803
  "metadata": {},
804
  "source": [
805
+ "For `family`, there should be a warning that 28 `class` values are not indicated."
806
  ]
807
  },
808
  {
 
814
  },
815
  {
816
  "cell_type": "code",
817
+ "execution_count": 21,
818
  "metadata": {},
819
  "outputs": [
820
  {
 
822
  "output_type": "stream",
823
  "text": [
824
  "<class 'pandas.core.frame.DataFrame'>\n",
825
+ "Index: 100 entries, 3723975 to 5416459\n",
826
  "Data columns (total 7 columns):\n",
827
  " # Column Non-Null Count Dtype \n",
828
  "--- ------ -------------- ----- \n",
829
+ " 0 kingdom 100 non-null object\n",
830
+ " 1 phylum 100 non-null object\n",
831
+ " 2 class 73 non-null object\n",
832
+ " 3 order 100 non-null object\n",
833
+ " 4 family 100 non-null object\n",
834
  " 5 genus 0 non-null object\n",
835
+ " 6 species 100 non-null object\n",
836
  "dtypes: object(7)\n",
837
+ "memory usage: 6.2+ KB\n"
838
  ]
839
  }
840
  ],
 
848
  "source": [
849
  "We should have\n",
850
  " - no instances of missing `kingdom`, `phylum`, `order`, or `family` \n",
851
+ " - 73 instances of missing `class`"
852
+ ]
853
+ },
854
+ {
855
+ "cell_type": "code",
856
+ "execution_count": 22,
857
+ "metadata": {},
858
+ "outputs": [
859
+ {
860
+ "data": {
861
+ "text/plain": [
862
+ "kingdom 4\n",
863
+ "phylum 15\n",
864
+ "class 24\n",
865
+ "order 107\n",
866
+ "family 314\n",
867
+ "genus 615\n",
868
+ "species 531\n",
869
+ "dtype: int64"
870
+ ]
871
+ },
872
+ "execution_count": 22,
873
+ "metadata": {},
874
+ "output_type": "execute_result"
875
+ }
876
+ ],
877
+ "source": [
878
+ "df_test_taxa.nunique()"
879
+ ]
880
+ },
881
+ {
882
+ "cell_type": "markdown",
883
+ "metadata": {},
884
+ "source": [
885
+ "We should get a warning of 4 unique values of `kingdom`."
886
+ ]
887
+ },
888
+ {
889
+ "cell_type": "code",
890
+ "execution_count": 23,
891
+ "metadata": {},
892
+ "outputs": [
893
+ {
894
+ "name": "stdout",
895
+ "output_type": "stream",
896
+ "text": [
897
+ "<class 'pandas.core.frame.DataFrame'>\n",
898
+ "Index: 10 entries, 1377769 to 2887231\n",
899
+ "Data columns (total 7 columns):\n",
900
+ " # Column Non-Null Count Dtype \n",
901
+ "--- ------ -------------- ----- \n",
902
+ " 0 kingdom 0 non-null object\n",
903
+ " 1 phylum 0 non-null object\n",
904
+ " 2 class 0 non-null object\n",
905
+ " 3 order 0 non-null object\n",
906
+ " 4 family 0 non-null object\n",
907
+ " 5 genus 10 non-null object\n",
908
+ " 6 species 10 non-null object\n",
909
+ "dtypes: object(7)\n",
910
+ "memory usage: 640.0+ bytes\n"
911
+ ]
912
+ }
913
+ ],
914
+ "source": [
915
+ "df_test_taxa.loc[df_test_taxa.species == \"(unidentified)\"].info(show_counts = True)"
916
  ]
917
  },
918
  {
919
  "cell_type": "markdown",
920
  "metadata": {},
921
+ "source": [
922
+ "And 10 instances of `(unidentified)` label for species."
923
+ ]
924
+ },
925
+ {
926
+ "cell_type": "code",
927
+ "execution_count": null,
928
+ "metadata": {},
929
+ "outputs": [],
930
  "source": []
931
  }
932
  ],