Update string split method to use keyword arguments for newer Pandas

This commit is contained in:
benjamin melançon 2023-02-06 10:03:22 -05:00
parent 34eb40a092
commit 7e2175860f

View file

@ -83,8 +83,8 @@ timelog["day_of_week"] = pd.to_datetime(timelog["date"]).dt.day_name()
# If a project has been specified (task prefixed with a colon), then put the
# project in its own column.
timelog['project'] = (np.where(timelog['description'].str.contains(': '), timelog['description'].str.split(': ', 1).str[0], None))
timelog['description'] = (np.where(timelog['description'].str.contains(': '), timelog['description'].str.split(': ', 1).str[1], timelog['description']))
timelog['project'] = (np.where(timelog['description'].str.contains(': '), timelog['description'].str.split(': ', n=1).str[0], None))
timelog['description'] = (np.where(timelog['description'].str.contains(': '), timelog['description'].str.split(': ', n=1).str[1], timelog['description']))
# Mid-work clean up of description and new project.
timelog['description'] = timelog['description'].str.strip()
@ -160,8 +160,8 @@ for preferred, alternatives in compound_project_tasks.items():
# If a compound project was specified, break that out into a sub-project (in
# Harvest, we use Task, which is really task type, for this).
timelog['subproject'] = (np.where(timelog['project'].str.contains(''), timelog['project'].str.split('', 1).str[1], None))
timelog['project'] = (np.where(timelog['project'].str.contains(''), timelog['project'].str.split('', 1).str[0], timelog['project']))
timelog['subproject'] = (np.where(timelog['project'].str.contains(''), timelog['project'].str.split('', n=1).str[1], None))
timelog['project'] = (np.where(timelog['project'].str.contains(''), timelog['project'].str.split('', n=1).str[0], timelog['project']))
# Replace irregular-but-known project names with ones timetracking tools use.
harvest_project_names = {