Compare alternatives (plus original) as lower case so every possible variation need not be explicit

This commit is contained in:
benjamin melançon 2021-05-28 14:39:51 -04:00
parent 369d727d65
commit e8ef6b0d7c

View file

@ -126,10 +126,13 @@ replacement_project_names = {
"Personal / external": ["Personal/external", "Personal", "External"], "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"], "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(): 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 # Condense duplicate entries by date, summing the minutes spent, and listing
# the first started and last recorded times for each task. # the first started and last recorded times for each task.