In [1]:
from mdt import *
#import seaborn
%matplotlib inline
%load_ext autoreload
%autoreload

Load Input


In [2]:
mp.P_T1 = r"^(.*):$"
mp.C_TITLE = ":"
cfg = yaml.load(open("mdt_config.yaml","r").read())
auth_token = cfg['auth_token']
mu.import_from_dropbox(auth_token, "tmp")
dt = mp.parse_md_files("./tmp/"+"*.taskpaper")
del dt["T2"];del dt["T3"];del dt["ID"]

Task Stats


In [3]:
# Filter tasks only
df = dt[dt.TXT.str.contains("^\s*- ")]
dfs = ms.add_stat(df, "done,p")
dfs.rename(columns={"Filename": "Week", "T1": "Project", "done": "Date", "p":"Time"}, inplace=True)

Daily Stats


In [4]:
daily = dfs.groupby(['Week',"Date"]).agg({'Time': ['sum'], 'TXT':'count', 'Project':'nunique'})
daily.columns = daily.columns.map(mu.flattenCols)
daily.rename(columns={"TXT_count": "Task_done"}, inplace=True)
daily['Ratio_Time'] = daily.Time_sum / 8
daily['Ratio_Task'] = daily.Task_done / 4
daily['Ratio_Project'] = daily.Project_nunique / 3
dstat = daily.fillna(0).sort_index(0, ascending=False).round(2)
dstat.to_csv("rpt/daily_stats.tsv",sep="\t")
dstat[:10]


Out[4]:
Project_nunique Task_done Time_sum Ratio_Time Ratio_Task Ratio_Project
Week Date
20172026 2017-02-26 1 5 3.0 0.38 1.25 0.33
20172019 2017-02-25 2 3 2.0 0.25 0.75 0.67
2017-02-23 1 7 0.0 0.00 1.75 0.33
2017-02-22 1 1 0.0 0.00 0.25 0.33
2017-02-21 1 1 0.0 0.00 0.25 0.33
2017-02-20 1 1 0.0 0.00 0.25 0.33
20170416 2017-04-17 1 1 0.0 0.00 0.25 0.33
2017-04-16 1 2 0.0 0.00 0.50 0.33
20170409 Back in LA 2017-04-17 1 2 0.0 0.00 0.50 0.33
2017-04-15 2 2 0.0 0.00 0.50 0.67

In [9]:
plt = daily.iloc[-10:,3:].plot(kind="bar", figsize=[15,3])
plt.axhline(y=1, linewidth=1, color = 'red', linestyle = 'dotted');


Weekly Stats


In [6]:
weekly = dfs.groupby(["Week"]).agg({'Time': ['sum'], 'TXT': 'count', 'Date': 'count'})
weekly.columns = weekly.columns.map(mu.flattenCols)
weekly.rename(columns={"TXT_count": "Task_total", "Date_count": "Task_done"}, inplace=True)
weekly.fillna(0).sort_index(0, ascending=False)
weekly['Ratio_Time'] = weekly.Time_sum / 40
weekly['Ratio_Task'] = weekly.Task_done / weekly.Task_total
wstat = weekly.fillna(0).sort_index(0, ascending=False).round(2)
wstat.to_csv("rpt/weekly_stats.tsv",sep="\t")
wstat


Out[6]:
Task_done Task_total Time_sum Ratio_Time Ratio_Task
Week
20172026 5 22 5.0 0.12 0.23
20172019 13 19 2.0 0.05 0.68
20170416 3 7 0.0 0.00 0.43
20170409 Back in LA 5 7 0.0 0.00 0.71
20170402 @ SF 8 16 0.0 0.00 0.50
20170326 18 31 0.0 0.00 0.58
20170319 7 16 0.0 0.00 0.44
20170312 1 4 0.0 0.00 0.25
20170305 13 22 2.0 0.05 0.59
20170226 21 40 5.0 0.12 0.52
20170219 13 19 2.0 0.05 0.68
20170212 12 20 0.0 0.00 0.60
20170205 22 26 34.0 0.85 0.85
20170129 6 19 12.0 0.30 0.32
20170122 13 26 19.0 0.48 0.50
20170115 11 23 17.0 0.42 0.48
20170108 20 33 17.0 0.42 0.61
20170101 14 24 18.0 0.45 0.58

In [10]:
plt = weekly.iloc[:,3:].plot(kind="bar", figsize=[10,3])
plt.axhline(y=1, linewidth=1, color = 'red', linestyle = 'dotted');


Journal Stats


In [8]:
# Filter journals only
dj = dt[dt.T1.str.contains("^20")]
djs = ms.add_stat(dj, "h")
djs.rename(columns={"Filename": "Week", "T1": "Date", "h":"Happiness"}, inplace=True)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-93e71e9e4396> in <module>()
      1 # Filter journals only
----> 2 dj = dt[dt.T1.str.contains("^20")]
      3 djs = ms.add_stat(dj, "h")
      4 djs.rename(columns={"Filename": "Week", "T1": "Date", "h":"Happiness"}, inplace=True)

/home/jink/bin/conda3/envs/py27/lib/python2.7/site-packages/pandas/core/frame.pyc in __getitem__(self, key)
   1956         if isinstance(key, (Series, np.ndarray, Index, list)):
   1957             # either boolean or fancy integer index
-> 1958             return self._getitem_array(key)
   1959         elif isinstance(key, DataFrame):
   1960             return self._getitem_frame(key)

/home/jink/bin/conda3/envs/py27/lib/python2.7/site-packages/pandas/core/frame.pyc in _getitem_array(self, key)
   1983     def _getitem_array(self, key):
   1984         # also raises Exception if object array with NA values
-> 1985         if com.is_bool_indexer(key):
   1986             # warning here just in case -- previously __setitem__ was
   1987             # reindexing but __getitem__ was not; it seems more reasonable to

/home/jink/bin/conda3/envs/py27/lib/python2.7/site-packages/pandas/core/common.pyc in is_bool_indexer(key)
    187             if not lib.is_bool_array(key):
    188                 if isnull(key).any():
--> 189                     raise ValueError('cannot index with vector containing '
    190                                      'NA / NaN values')
    191                 return False

ValueError: cannot index with vector containing NA / NaN values

Writing Amount


In [ ]:
djsa = djs.groupby(["Date"]).agg({'TXT': ['count']})
plt = djsa[-10:].plot(kind="bar", figsize=[15,3])
plt.legend_.remove()
plt.axhline(y=5, linewidth=1, color = 'red', linestyle = 'dotted');

Happiness


In [ ]:
djs[~djs.Happiness.isnull()]

In [ ]:
djsa = djs[~djs.Happiness.isnull()].groupby(["Date"]).agg({'Happiness': ['mean']})
plt = djsa.plot(kind="bar", figsize=[10,3])
plt.legend_.remove()
plt.axhline(y=3.5, linewidth=1, color = 'red', linestyle = 'dotted');