From 05dc8b7a0f441e1ba90a61833d7b68dced5015b6 Mon Sep 17 00:00:00 2001 From: Fernando Wittmann Date: Wed, 15 Nov 2023 20:56:01 -0300 Subject: [PATCH] Fix issue #30 - Clip reference year to current year when calculating cit/year to avoid zero division in cit/year --- sortgs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sortgs.py b/sortgs.py index 6e114b1..2f5f890 100755 --- a/sortgs.py +++ b/sortgs.py @@ -280,8 +280,8 @@ def main(): columns=['Author', 'Title', 'Citations', 'Year', 'Publisher', 'Venue', 'Source']) data.index.name = 'Rank' - # Add columns with number of citations per year - data['cit/year']=data['Citations']/(end_year + 1 - data['Year']) + # Avoid years that are higher than the current year by clipping it to end_year + data['cit/year']=data['Citations']/(end_year + 1 - data['Year'].clip(upper=end_year)) data['cit/year']=data['cit/year'].round(0).astype(int) # Sort by the selected columns, if exists