datalife-2019/notebook.ipynb

509 lines
24 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Taskwarrior"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"from tasklib import TaskWarrior\n",
"import datetime\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"Year Month Added Completed Deleted Net\n",
"---- --------- ----- --------- ------- ---\n",
"2019 January 18 19 0 -1\n",
" February 9 7 0 2\n",
" March 27 23 0 4\n",
" April 13 14 3 -4\n",
" May 10 9 0 1\n",
" June 17 13 0 4\n",
" July 17 17 0 0\n",
" August 35 37 0 -2\n",
" September 22 24 1 -3\n",
" October 19 15 2 2\n",
" November 17 16 0 1\n",
" December 37 42 1 -6\n",
" \n",
" Total 241 236 7 5 "
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [],
"source": [
"with open('data/task.json', 'r') as myfile:\n",
" task = json.load(myfile)\n",
"\n",
"tasks = pd.DataFrame.from_dict(task)\n",
"tasks.set_axis(tasks['entry'], axis='index', inplace=True)\n",
"tasks = tasks.drop(['annotations', 'depends', 'description', 'parent', 'uuid', 'entry'], axis=1)\n",
"only2019(tasks).count()"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([164., 3., 27., 2., 11., 1., 2., 1., 2., 2.]),\n",
" array([ 0. , 1.5, 3. , 4.5, 6. , 7.5, 9. , 10.5, 12. , 13.5, 15. ]),\n",
" <a list of 10 Patch objects>)"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uID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1Fup9vatK3fyFl3+fzef1PuXw/0jl1GulJ8lJJyyvrG8oZcg5pTH9KCvaacbmtA/Lyv9Uf/9bgb8aajYLKdN1bm9S7mfTmaH9d+eeB3SLi7Abb7EG6YHljxzq8BUZ6bG3uYxfSE8NBW/AKZ5tV2hW9WfHylfaJpDdw69ftQ7qy/PJW7tZWI+lw0qvR/+eQHxlf0ZuZFc5X9GZmhXPQm5kVzkFvZlY4B72ZWeEc9GZmhXPQm5kV7v8DqVU+C7hdbGQAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"l = only2019(tasks).tags.dropna().to_list()\n",
"flat_list = [item for sublist in l for item in sublist]\n",
"\n",
"plt.hist(flat_list)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Habits"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import calendar\n",
"import matplotlib \n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 183,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Days done: Meditate 64\n",
"Exercise 65\n",
"Read 69\n",
"Journal 49\n",
"devlog 32\n",
"Plants 38\n",
"Draw 12\n",
"dtype: int64\n",
"Non-streak days: Meditate 176\n",
"Exercise 179\n",
"Read 161\n",
"Journal 70\n",
"devlog 154\n",
"Plants 120\n",
"Draw 252\n",
"dtype: int64\n",
"Streak days: Meditate 35\n",
"Exercise 31\n",
"Read 45\n",
"Journal 156\n",
"devlog 89\n",
"Plants 117\n",
"Draw 11\n",
"dtype: int64\n",
"Longest streak: Meditate 17\n",
"Exercise 11\n",
"Read 12\n",
"Journal 55\n",
"devlog 29\n",
"Plants 87\n",
"Draw 17\n",
"dtype: int64\n",
"Longest zeros: Meditate 23\n",
"Exercise 26\n",
"Read 43\n",
"Journal 27\n",
"devlog 121\n",
"Plants 54\n",
"Draw 229\n",
"dtype: int64\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Meditate</th>\n",
" <th>Exercise</th>\n",
" <th>Read</th>\n",
" <th>Journal</th>\n",
" <th>devlog</th>\n",
" <th>Plants</th>\n",
" <th>Draw</th>\n",
" </tr>\n",
" <tr>\n",
" <th>month</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.133333</td>\n",
" <td>0.266667</td>\n",
" <td>0.000000</td>\n",
" <td>0.900000</td>\n",
" <td>0.000000</td>\n",
" <td>1.133333</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.387097</td>\n",
" <td>0.193548</td>\n",
" <td>0.193548</td>\n",
" <td>0.645161</td>\n",
" <td>0.000000</td>\n",
" <td>0.516129</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.500000</td>\n",
" <td>0.266667</td>\n",
" <td>0.166667</td>\n",
" <td>0.666667</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.516129</td>\n",
" <td>0.838710</td>\n",
" <td>0.967742</td>\n",
" <td>0.774194</td>\n",
" <td>0.064516</td>\n",
" <td>0.612903</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.806452</td>\n",
" <td>0.741935</td>\n",
" <td>0.935484</td>\n",
" <td>1.161290</td>\n",
" <td>1.225806</td>\n",
" <td>1.193548</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>1.133333</td>\n",
" <td>0.600000</td>\n",
" <td>1.233333</td>\n",
" <td>1.300000</td>\n",
" <td>1.066667</td>\n",
" <td>1.333333</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>0.774194</td>\n",
" <td>1.064516</td>\n",
" <td>0.580645</td>\n",
" <td>0.935484</td>\n",
" <td>1.032258</td>\n",
" <td>1.193548</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>0.700000</td>\n",
" <td>0.733333</td>\n",
" <td>0.800000</td>\n",
" <td>1.233333</td>\n",
" <td>1.000000</td>\n",
" <td>0.333333</td>\n",
" <td>0.533333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>0.387097</td>\n",
" <td>0.548387</td>\n",
" <td>1.096774</td>\n",
" <td>0.709677</td>\n",
" <td>0.612903</td>\n",
" <td>0.000000</td>\n",
" <td>0.612903</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Meditate Exercise Read Journal devlog Plants Draw\n",
"month \n",
"4 0.133333 0.266667 0.000000 0.900000 0.000000 1.133333 0.000000\n",
"5 0.387097 0.193548 0.193548 0.645161 0.000000 0.516129 0.000000\n",
"6 0.500000 0.266667 0.166667 0.666667 0.000000 0.000000 0.000000\n",
"7 0.516129 0.838710 0.967742 0.774194 0.064516 0.612903 0.000000\n",
"8 0.806452 0.741935 0.935484 1.161290 1.225806 1.193548 0.000000\n",
"9 1.133333 0.600000 1.233333 1.300000 1.066667 1.333333 0.000000\n",
"10 0.774194 1.064516 0.580645 0.935484 1.032258 1.193548 0.000000\n",
"11 0.700000 0.733333 0.800000 1.233333 1.000000 0.333333 0.533333\n",
"12 0.387097 0.548387 1.096774 0.709677 0.612903 0.000000 0.612903"
]
},
"execution_count": 183,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#colNames = ['date', 'Godmode', 'Meditate', 'Exercise', 'Piano','Read', 'Journal', 'Gratitude', 'devlog','Plants', 'Job', 'Draw']\n",
"checks = pd.read_csv('LoopHabits/Checkmarks.csv', header=0)\n",
"checks.set_axis(checks['date'], axis='index', inplace=True)\n",
"checks = checks.drop(['Godmode', 'Piano', 'Gratitude', 'Job', 'date'], axis=1)\n",
"df = MarchOnwards(only2019(checks))\n",
"print(\"Days done: \" + str(countValue(2, df)))\n",
"print(\"Non-streak days: \" + str(countZeros(df)))\n",
"print(\"Streak days: \" + str(countValue(1, df)))\n",
"print(\"Longest streak: \" + str(df.apply(longestStreak, axis=0)))\n",
"print(\"Longest zeros: \" + str(df.apply(longestZero, axis=0)))\n",
"#print(\"Best month: \" + str(sumMonth(df)))\n",
"sumMonth(df)\n",
"meanMonth(df)\n",
"#print(\"Worst month: \" + calendar.month_name[int(sumMonth(df).idxmin())])\n",
"#plotScore(df)"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [],
"source": [
"def only2019(df):\n",
" return df.filter(like='2019', axis=0)\n",
"\n",
"def MarchOnwards(df):\n",
" # For habits only, lost my phone in late Febuary, didn't have a recent backup\n",
" return df.filter(regex='[0-9]{4}-(0?[4-9]|1?[0-2])-[0-9]{2}', axis=0)\n",
"\n",
"def longestZero(df):\n",
" # reverse the series so dates are ascending (increasing?)\n",
" # pad out the series with 0s, then diff it to track total, use that total to calculate highest streak\n",
" # streak increases when sum is 0\n",
" diffStreak = pd.concat([pd.Series([0]) , df[::-1], pd.Series([0])]).diff().tolist()\n",
" runningSum = 0\n",
" streak = 0\n",
" streakList = []\n",
" for e in diffStreak[1:-1]:\n",
" runningSum += e\n",
" if runningSum == 0:\n",
" streak += 1\n",
" else:\n",
" streakList.append(streak)\n",
" streak = 0\n",
" return max(streakList)\n",
"\n",
"def longestStreak(df):\n",
" # reverse the series so dates are ascending (increasing?)\n",
" # pad out the series with 0s, then diff it to track total, use that total to calculate highest streak\n",
" # streak increases when sum is non-zero\n",
" diffStreak = pd.concat([pd.Series([0]) , df[::-1], pd.Series([0])]).diff().tolist()\n",
" runningSum = 0\n",
" streak = 0\n",
" streakList = []\n",
" for e in diffStreak[1:-1]:\n",
" runningSum += e\n",
" if runningSum != 0:\n",
" streak += 1\n",
" else:\n",
" streakList.append(streak)\n",
" streak = 0\n",
" return max(streakList)\n",
"\n",
"def sumMonth(df):\n",
" df2 = df.reset_index()\n",
" df['month'] = pd.DatetimeIndex(df2['date']).month\n",
" return df.groupby(['month']).sum()\n",
"\n",
"def meanMonth(df):\n",
" df2 = df.reset_index()\n",
" df['month'] = pd.DatetimeIndex(df2['date']).month\n",
" return df.groupby(['month']).mean()\n",
"\n",
"def plotScore(df):\n",
" df = meanMonth(df)\n",
" plt.plot(df)\n",
" plt.show()\n",
"\n",
"def countZeros(df):\n",
" return countValue(0, df)\n",
"\n",
"def countValue(countValue, df):\n",
" return (df == countValue).astype(int).sum()\n"
]
},
{
"cell_type": "code",
"execution_count": 83,
"metadata": {},
"outputs": [],
"source": [
"# checking for CSV of simply one habit\n",
"\n",
"colNames = ['date', 'value']\n",
"meditateChecks = pd.read_csv('LoopHabits/002 Meditate/Checkmarks.csv', names=colNames, header=None)\n",
"meditateScore = pd.read_csv('LoopHabits/002 Meditate/Scores.csv', names=colNames, header=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# might be broken now\n",
"# need to deal with dates in columns\n",
"meditateChecks.set_axis(checks['date'], axis='index', inplace=True)\n",
"df = MarchOnwards(only2019(meditateChecks))\n",
"print(\"Days done: \" + str(countValue(2, df)))\n",
"print(\"Non-streak days: \" + str(countZeros(df)))\n",
"print(\"Streak days: \" + str(countValue(1, df)))\n",
"print(\"Longest streak: \" + str(longestStreak(df)))\n",
"print(\"Longest zeros: \" + str(longestZero(df)))\n",
"print(\"Best month: \" + calendar.month_name[int(sumMonth(df).idxmax())])\n",
"print(\"Worst month: \" + calendar.month_name[int(sumMonth(df).idxmin())])\n",
"plotScore(df)"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"306\n"
]
},
{
"data": {
"text/plain": [
"299"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Total days for habits: 306\n",
"# How come when counting streaks I only get 299?\n",
"# missing 1 week??\n",
"print(72 + 195 + 39)\n",
"longestStreak(onlyMarch(only2019(meditateChecks))) + longestZero(onlyMarch(only2019(meditateChecks)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Why don't the above two numbers match??"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}