From e8ef6b0d7c355d91bb8e8b889d9d8f33b1eb0763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Melan=C3=A7on?= Date: Fri, 28 May 2021 14:39:51 -0400 Subject: [PATCH] Compare alternatives (plus original) as lower case so every possible variation need not be explicit --- pomodoro_to_harvest.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pomodoro_to_harvest.py b/pomodoro_to_harvest.py index 12a6506..e651168 100644 --- a/pomodoro_to_harvest.py +++ b/pomodoro_to_harvest.py @@ -126,10 +126,13 @@ replacement_project_names = { "Personal / external": ["Personal/external", "Personal", "External"], "Near North camp": ["Near North Camp", "Near North defense", "Encampment support", "Camp support", "NN camp defense", "NN camp", "NN defense", "Near North camp defense"], } -# TODO Probably put all alternatives in lower case and do str.lower() on -# project just before the "is in" check. for preferred, alternatives in replacement_project_names.items(): - timelog.loc[timelog.project.isin(alternatives), "project"] = preferred + # We compare all alternatives to lower case versions, and add the + # preferred output to this list for that purpose, but note that what we use + # as preferred retains its capitalization. + alternatives.append(preferred) + alternatives = [item.lower() for item in alternatives] + timelog.loc[timelog.project.str.lower().isin(alternatives), "project"] = preferred # Condense duplicate entries by date, summing the minutes spent, and listing # the first started and last recorded times for each task.