datalife-2019/notebook.ipynb

904 lines
36 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Common functions"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"from tasklib import TaskWarrior\n",
"import datetime\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import re\n",
"from sklearn.feature_extraction.text import CountVectorizer\n",
"from sklearn.feature_extraction.text import TfidfVectorizer"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def only2019(df):\n",
" return df.filter(like='2019', axis=0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Shaarli"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Journal"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### import journal into habits data\n",
"\n",
"### TF-IDF for jrnl"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"https://kavita-ganesan.com/extracting-keywords-from-text-tfidf/"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"def pre_process(text):\n",
" # lowercase\n",
" text=text.lower()\n",
" #remove tags\n",
" #text=re.sub(\"<!--?.*?-->\",\"\",text)\n",
" # remove special characters and digits\n",
" text=re.sub(\"(\\\\d|\\\\W)+\",\" \",text)\n",
" return text\n",
"\n",
"def sort_coo(coo_matrix):\n",
" tuples = zip(coo_matrix.col, coo_matrix.data)\n",
" return sorted(tuples, key=lambda x: (x[1], x[0]), reverse=True)\n",
" \n",
"def extract_topn_from_vector(feature_names, sorted_items, topn=10):\n",
" \"\"\"get the feature names and tf-idf score of top n items\"\"\"\n",
" \n",
" #use only topn items from vector\n",
" sorted_items = sorted_items[:topn]\n",
" \n",
" score_vals = []\n",
" feature_vals = []\n",
" \n",
" # word index and corresponding tf-idf score\n",
" for idx, score in sorted_items:\n",
" \n",
" #keep track of feature name and its corresponding score\n",
" score_vals.append(round(score, 3))\n",
" feature_vals.append(feature_names[idx])\n",
" \n",
" #create a tuples of feature,score\n",
" #results = zip(feature_vals,score_vals)\n",
" results= {}\n",
" for idx in range(len(feature_vals)):\n",
" results[feature_vals[idx]]=score_vals[idx]\n",
" \n",
" return results\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"===Keywords===\n",
"rain 0.699\n",
"years 0.658\n",
"spokes 0.584\n",
"new 0.567\n",
"dont 0.545\n",
"quite 0.507\n",
"feeling 0.507\n",
"freedom 0.502\n",
"despair 0.502\n",
"awaits 0.502\n",
"voices 0.501\n",
"hearing 0.501\n",
"hard 0.495\n",
"better 0.494\n",
"news 0.488\n",
"uber 0.469\n",
"pay 0.468\n",
"graveyard 0.443\n",
"cult 0.443\n",
"repeatedly 0.437\n",
"tech 0.433\n",
"laurel 0.431\n",
"wedding 0.426\n",
"wont 0.422\n",
"bit 0.418\n",
"tour 0.404\n",
"able 0.394\n",
"strategy 0.392\n",
"like 0.392\n",
"clouds 0.383\n",
"travelling 0.383\n",
"watching 0.383\n",
"sources 0.377\n",
"flows 0.377\n",
"doodling 0.374\n",
"successful 0.373\n",
"imagine 0.373\n",
"ye 0.373\n",
"tell 0.371\n",
"im 0.37\n"
]
}
],
"source": [
"with open('data/tiddlers.json' , 'r') as file:\n",
" tiddly = json.load(file)\n",
" \n",
"jrnl = pd.DataFrame.from_dict(tiddly)\n",
"jrnl.set_axis(jrnl['title'], axis='index', inplace=True)\n",
"jrnl = only2019(jrnl.drop(['created', 'modified'], axis=1))\n",
"jrnl.drop(['title', 'tags'], axis=1, inplace=True)\n",
"jrnl['text'] = jrnl['text'].apply(lambda x: pre_process(x))\n",
" \n",
"#get the text column \n",
"docs=jrnl['text'].tolist()\n",
"\n",
"tfidf = TfidfVectorizer(stop_words='english')\n",
"X = tfidf.fit_transform(docs)\n",
"\n",
"#sort the tf-idf vectors by descending order of scores\n",
"sorted_items=sort_coo(X.tocoo())\n",
" \n",
"#extract only the top n; n here is 10\n",
"keywords=extract_topn_from_vector(tfidf.get_feature_names(),sorted_items,40)\n",
" \n",
"# now print the results\n",
"#print(\"\\n=====Doc=====\")\n",
"#print(doc)\n",
"print(\"\\n===Keywords===\")\n",
"for k in keywords:\n",
" print(k,keywords[k])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"According to habits I have 49 Journal entries\n",
"\n",
"\n",
"Let's compare that with this data"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [],
"source": [
"import json"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tags 87\n",
"text 88\n",
"title 88\n",
"dtype: int64"
]
},
"execution_count": 106,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with open('data/tiddlers.json' , 'r') as file:\n",
" tiddly = json.load(file)\n",
"\n",
"jrnl = pd.DataFrame.from_dict(tiddly)\n",
"jrnl.set_axis(jrnl['title'], axis='index', inplace=True)\n",
"jrnl = only2019(jrnl.drop(['created', 'modified'], axis=1))\n",
"jrnl.count()"
]
},
{
"cell_type": "code",
"execution_count": 107,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tags 30\n",
"text 30\n",
"title 30\n",
"dtype: int64"
]
},
"execution_count": 107,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sameDay = jrnl\n",
"sameDay['title'] = sameDay.title.map(lambda x: x[:-8])\n",
"sameDay[sameDay['title'].duplicated(keep=False)].count()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Where are the [87-15=(73)] - 49 = 23 entries that exist but aren't in my loop Habits?\n",
"\n",
"23 Entries before March?"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [],
"source": [
"def beforeMarch(df):\n",
" return df.filter(regex='(January|Febuary|March)', axis=0)"
]
},
{
"cell_type": "code",
"execution_count": 121,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tags 23\n",
"text 23\n",
"title 23\n",
"dtype: int64"
]
},
"execution_count": 121,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"beforeMarch(jrnl).count()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Taskwarrior"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"description 241\n",
"due 107\n",
"end 241\n",
"id 241\n",
"imask 0\n",
"mask 0\n",
"modified 241\n",
"priority 3\n",
"project 188\n",
"recur 0\n",
"status 241\n",
"tags 215\n",
"until 0\n",
"urgency 241\n",
"dtype: int64"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with open('data/task.json', 'r') as myfile:\n",
" task = json.load(myfile)\n",
"\n",
"# Convert the data into a data frame\n",
"# Some preliminary analysis\n",
"tasks = pd.DataFrame.from_dict(task)\n",
"tasks.set_axis(tasks['entry'], axis='index', inplace=True)\n",
"tasks = tasks.drop(['annotations', 'depends', 'parent', 'uuid', 'entry'], axis=1)\n",
"only2019(tasks).count()"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"16 unique tags\n",
"215 tagged items\n",
"The tags are: {'rocks', 'friends', 'd.tech', 'chores', 'job', 'prpj', 'fam', 'artifex', 'contact', 'd.infra', 'fun', 'piracy', 'work', 'uni', 'life', 'travel'}\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzkAAAHVCAYAAADSCzXJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3X28bHVdL/DPV46KaIjI0RTQQ16uZd2r6bnmY1FYqZToTVMzBePGNS3S8mV4rfSVeS9qN8tKDZ8gNdPwiTRNRQg1QQ/IMz7wQlKC4JgPpV5N7Hf/WGvDsJl99j57Zs7e/Hy/X6/9mjVr1pr1/c2sNWs+67fW7GqtBQAAoBe32OgCAAAA5knIAQAAuiLkAAAAXRFyAACArgg5AABAV4QcAACgK0IOAADQFSEHAADoipADAAB0ZctGF5AkBxxwQNu2bdtGlwEAAGxS55xzzhdba1vXMu2mCDnbtm3Ljh07NroMAABgk6qqf1zrtE5XAwAAuiLkAAAAXRFyAACArgg5AABAV4QcAACgK0IOAADQFSEHAADoipADAAB0RcgBAAC6IuQAAABdEXIAAICuCDkAAEBXhBwAAKArQg4AANAVIQcAAOiKkAMAAHRFyAEAALoi5AAAAF0RcgAAgK5s2egCNqNtx79n3fNeccIRc6wEAADYXXpyAACArgg5AABAV4QcAACgK0IOAADQFSEHAADoipADAAB0RcgBAAC6IuQAAABdEXIAAICuCDkAAEBXhBwAAKArQg4AANCVVUNOVb2uqq6tqoumPPbsqmpVdcB4v6rq5VV1WVVdUFX3XUTRAAAAK1lLT85JSR6+fGRVHZzkJ5N8fmL0I5IcOv4dm+SVs5cIAACwdquGnNbamUm+NOWhlyV5TpI2Me7IJH/RB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+omrcHWMv6Lmt03/zsJmsdd2ZcRn7ZAhF993kPYdsUnpyAIDdMvY8HJ3hgvMNV8M/sf1Ykj/Y6FqYXVU9LMPZAn8i4LBeenIAAICu6MkBAAC6IuQAAABdEXIAAICuCDkAAEBXhBwAAKAr/x/4UhPI6+SXOgAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 1008x576 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# How many of each tag did I do?\n",
"\n",
"l = only2019(tasks).tags.dropna().to_list()\n",
"flat_list = [item for sublist in l for item in sublist]\n",
"print(str(len(set(flat_list))) + \" unique tags\")\n",
"print(str(len(l)) + \" tagged items\")\n",
"print(\"The tags are: \" + str(set(flat_list)))\n",
"\n",
"fig = plt.figure(figsize=(14,8))\n",
"plt.hist(flat_list, rwidth=1/3, align='left', bins=16)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"count 241\n",
"unique 216\n",
"top fold clothes\n",
"freq 7\n",
"Name: description, dtype: object\n",
"\n",
"Repeated descriptions: \n",
" laundry\n",
" haircut\n",
" fold clothes\n",
" recharge my way\n",
" change sheets\n",
" cut hair\n",
" buy condoms\n",
" schedule counsellor meeting\n",
" cut nails\n",
" recharge myway\n",
" book counsellor meeting\n",
" shave\n",
" do laundry\n"
]
}
],
"source": [
"# Description mining\n",
"\n",
"l = only2019(tasks).description\n",
"print(l.describe())\n",
"print()\n",
"print(\"Repeated descriptions: \")\n",
"for e in l[l.duplicated(keep=False)].unique():\n",
" print(\" \" + e)"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [],
"source": [
"# Most described task?\n",
"## TODO"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Habits"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import calendar\n",
"import matplotlib \n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 105,
"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": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#colNames = ['date', 'Godmode', 'Meditate', 'Exercise', 'Piano','Read', 'Journal', 'Gratitude', 'devlog','Plants', 'Job', 'Draw']\n",
"checks = pd.read_csv('data/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": 102,
"metadata": {},
"outputs": [],
"source": [
"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
}