From 796284931ee1e8c3ac394e0ca5c81cd4861149c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Tue, 27 Apr 2021 21:45:37 -0400 Subject: [PATCH] Split out project into own column if it had been provided (with colon) --- pomodoro_to_harvest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pomodoro_to_harvest.py b/pomodoro_to_harvest.py index f9a1463..02f8d0a 100644 --- a/pomodoro_to_harvest.py +++ b/pomodoro_to_harvest.py @@ -1,4 +1,5 @@ import pandas as pd +import numpy as np # import matplotlib.pyplot as plt timelog = pd.read_csv("timelog-titled.csv") @@ -12,6 +13,10 @@ timelog["time"] = 30 timelog["date"] = timelog["started"].dt.tz_convert("US/Pacific").dt.date timelog["day_of_week"] = pd.to_datetime(timelog["date"]).dt.day_name() +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'])) + + # Condense duplicate entries by date, summing the minutes spent, and listing # the first started and last recorded times for each task. tl = timelog.groupby(["date", "description"]).agg({"time": 'sum', "started": 'min', "recorded": 'max'}).reset_index()