From 82e3ef48a240c5151d5d60e913a0cd95028af87b Mon Sep 17 00:00:00 2001 From: Jonathan Chan Date: Wed, 14 Jun 2023 16:50:36 +1000 Subject: [PATCH] Fixed dividing by zero error --- coastsnap/images_snapshot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coastsnap/images_snapshot.py b/coastsnap/images_snapshot.py index 0a6f6cc..5d15306 100644 --- a/coastsnap/images_snapshot.py +++ b/coastsnap/images_snapshot.py @@ -107,7 +107,11 @@ for site in os.listdir(images_dir): # Loop through SITES # Add site stability data (# registered / # processed) for i, row in stats_csv.iterrows(): - stability = "{0:.0%}".format(stats_csv.at[i, '# registered'] / stats_csv.at[i, '# photoshop']) + + if stats_csv.at[i, '# photoshop'] != 0: + stability = "{0:.0%}".format(stats_csv.at[i, '# registered'] / stats_csv.at[i, '# photoshop']) + else: + stability = 'NaN' # or whatever value makes sense in your context stats_csv.at[i,'stability'] = stability stats_csv.set_index('site', inplace = True)