Skip to content

Commit

Permalink
round geo thresholds down to 5 decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
pleary committed Oct 3, 2024
1 parent fe9b9c2 commit 38d53ea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/model_taxonomy_dataframe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pandas as pd
import math


class ModelTaxonomyDataframe:
Expand Down Expand Up @@ -38,6 +39,10 @@ def load_mapping(self, path, thresholds_path):
if thresholds_path is not None:
thresholds = pd.read_csv(thresholds_path)[["taxon_id", "thres"]]. \
rename(columns={"thres": "geo_threshold"}).set_index("taxon_id").sort_index()
# round thresholds down to 5 decimal places
thresholds["geo_threshold"] = thresholds["geo_threshold"].apply(
lambda x: math.floor(x * 100000) / 100000
)
self.df = self.df.join(thresholds)

# create a data frame with just the leaf taxa using leaf_class_id as the index
Expand Down

0 comments on commit 38d53ea

Please sign in to comment.