488 lines
14 KiB
Plaintext
488 lines
14 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Taskwarrior"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 57,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import json\n",
|
|
"from tasklib import TaskWarrior\n",
|
|
"import datetime\n",
|
|
"import pandas as pd"
|
|
]
|
|
},
|
|
{
|
|
"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": 61,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"with open('data/task.json', 'r') as myfile:\n",
|
|
" task = json.load(myfile)\n",
|
|
"\n",
|
|
"tasks = pd.DataFrame.from_dict(task)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# this was dumb, using a list\n",
|
|
"\n",
|
|
"tagslist = []\n",
|
|
"for e in task:\n",
|
|
" # filter based on date\n",
|
|
" ###\n",
|
|
" # only check tags where they exist\n",
|
|
" if 'tags' in e.keys():\n",
|
|
" count += 1\n",
|
|
" tagslist.append(e[\"tags\"])\n",
|
|
"\n",
|
|
"print(tagslist)"
|
|
]
|
|
},
|
|
{
|
|
"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": 182,
|
|
"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
|
|
}
|