444 lines
23 KiB
Plaintext
444 lines
23 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"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": 145,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "KeyError",
|
|
"evalue": "'date'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2524\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2525\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2526\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;31mKeyError\u001b[0m: 'date'",
|
|
"\nDuring handling of the above exception, another exception occurred:\n",
|
|
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
|
|
"\u001b[0;32m<ipython-input-145-4079aebead98>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# might be broken now\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m# need to deal with dates in columns\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mmeditateChecks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_axis\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchecks\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'date'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'index'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minplace\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mMarchOnwards\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0monly2019\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmeditateChecks\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Days done: \"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcountValue\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 2137\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2138\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2139\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem_column\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2140\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2141\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_getitem_column\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m_getitem_column\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 2144\u001b[0m \u001b[0;31m# get column\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2145\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_unique\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2146\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_item_cache\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2147\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2148\u001b[0m \u001b[0;31m# duplicate columns & possible reduce dimensionality\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36m_get_item_cache\u001b[0;34m(self, item)\u001b[0m\n\u001b[1;32m 1840\u001b[0m \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcache\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1841\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mres\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1842\u001b[0;31m \u001b[0mvalues\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_data\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1843\u001b[0m \u001b[0mres\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_box_item_values\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalues\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1844\u001b[0m \u001b[0mcache\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mres\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pandas/core/internals.py\u001b[0m in \u001b[0;36mget\u001b[0;34m(self, item, fastpath)\u001b[0m\n\u001b[1;32m 3841\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3842\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0misna\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3843\u001b[0;31m \u001b[0mloc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3844\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3845\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0misna\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;32m~/.local/lib/python3.6/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2525\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2526\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2527\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2528\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2529\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n",
|
|
"\u001b[0;31mKeyError\u001b[0m: 'date'"
|
|
]
|
|
}
|
|
],
|
|
"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.6.5"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|