Repository where I mostly put random python scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1168 lines
352 KiB

  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "Let's do a deep dive and start visualizing my life using Fitbit and Matplotlib. \n",
  8. "\n",
  9. "# What is Fitbit\n",
  10. "\n",
  11. "[Fitbit](https://www.fitbit.com) is a fitness watch that tracks your sleep, heart rate, and activity.\n",
  12. "Fitbit is able to track your steps, however, it is also able to detect multiple types of activity\n",
  13. "like running, walking, \"sport\" and biking."
  14. ]
  15. },
  16. {
  17. "cell_type": "markdown",
  18. "metadata": {},
  19. "source": [
  20. "# What is Matplotlib\n",
  21. "\n",
  22. "[Matplotlib](https://matplotlib.org/) is a python visualization library that enables you to create bar graphs, line graphs, distributions and many more things.\n",
  23. "Being able to visualize your results is essential to any person working with data at any scale.\n",
  24. "Although I like [GGplot](https://ggplot2.tidyverse.org/) in R more than Matplotlib, Matplotlib is still my go to graphing library for Python. "
  25. ]
  26. },
  27. {
  28. "cell_type": "markdown",
  29. "metadata": {},
  30. "source": [
  31. "# Getting Your Fitbit Data\n",
  32. "\n",
  33. "There are two main ways that you can get your Fitbit data:\n",
  34. "\n",
  35. "- Fitbit API\n",
  36. "- Data Archival Export\n",
  37. "\n",
  38. "\n",
  39. "Since connecting to the API and setting up all the web hooks can be a pain, I'm just going to use the data export option because this is only for one person.\n",
  40. "You can export your data here: [https://www.fitbit.com/settings/data/export](https://www.fitbit.com/settings/data/export).\n",
  41. "\n",
  42. "![Data export on fitbit's website](dataExport.png)\n",
  43. "\n",
  44. "The Fitbit data archive was very organized and kept meticulous records of everything. \n",
  45. "All of the data was organized in separate JSON files labeled by date.\n",
  46. "Fitbit keeps around 1MB of data on you per day; most of this data is from the heart rate sensors.\n",
  47. "Although 1MB of data may sound like a ton of data, it is probably a lot less if you store it in formats other than JSON. \n",
  48. "When I downloaded the compressed file it was 20MB, but when I extracted it, it was 380MB!\n",
  49. "I've only been using Fitbit for 11 months at this point. \n",
  50. "\n",
  51. "![compressed data](compression.png)"
  52. ]
  53. },
  54. {
  55. "cell_type": "markdown",
  56. "metadata": {},
  57. "source": [
  58. "## Sleep\n",
  59. "\n",
  60. "Sleep is something fun to visualize.\n",
  61. "No matter how much of it you get you still feel tired as a college student.\n",
  62. "In the \"sleep_score\" folder of the exported data you will find a single CSV file with your resting heart rate and Fitbit's computed sleep scores.\n",
  63. "Interesting enough, this is the only file that comes in the CSV format, everything else is JSON file. \n",
  64. "\n",
  65. "We can read in all the data using a single liner with the [Pandas](https://pandas.pydata.org/) python library.\n"
  66. ]
  67. },
  68. {
  69. "cell_type": "code",
  70. "execution_count": 1,
  71. "metadata": {},
  72. "outputs": [],
  73. "source": [
  74. "import matplotlib.pyplot as plt\n",
  75. "import pandas as pd\n",
  76. "\n",
  77. "sleep_score_df = pd.read_csv('data/sleep/sleep_score.csv')"
  78. ]
  79. },
  80. {
  81. "cell_type": "code",
  82. "execution_count": 2,
  83. "metadata": {},
  84. "outputs": [
  85. {
  86. "name": "stdout",
  87. "output_type": "stream",
  88. "text": [
  89. " sleep_log_entry_id timestamp overall_score \\\n",
  90. "0 26093459526 2020-02-27T06:04:30Z 80 \n",
  91. "1 26081303207 2020-02-26T06:13:30Z 83 \n",
  92. "2 26062481322 2020-02-25T06:00:30Z 82 \n",
  93. "3 26045941555 2020-02-24T05:49:30Z 79 \n",
  94. "4 26034268762 2020-02-23T08:35:30Z 75 \n",
  95. ".. ... ... ... \n",
  96. "176 23696231032 2019-09-02T07:38:30Z 79 \n",
  97. "177 23684345925 2019-09-01T07:15:30Z 84 \n",
  98. "178 23673204871 2019-08-31T07:11:00Z 74 \n",
  99. "179 23661278483 2019-08-30T06:34:00Z 73 \n",
  100. "180 23646265400 2019-08-29T05:55:00Z 80 \n",
  101. "\n",
  102. " composition_score revitalization_score duration_score \\\n",
  103. "0 20 19 41 \n",
  104. "1 22 21 40 \n",
  105. "2 22 21 39 \n",
  106. "3 17 20 42 \n",
  107. "4 20 16 39 \n",
  108. ".. ... ... ... \n",
  109. "176 20 20 39 \n",
  110. "177 22 21 41 \n",
  111. "178 18 21 35 \n",
  112. "179 17 19 37 \n",
  113. "180 21 21 38 \n",
  114. "\n",
  115. " deep_sleep_in_minutes resting_heart_rate restlessness \n",
  116. "0 65 60 0.117330 \n",
  117. "1 85 60 0.113188 \n",
  118. "2 95 60 0.120635 \n",
  119. "3 52 61 0.111224 \n",
  120. "4 43 59 0.154774 \n",
  121. ".. ... ... ... \n",
  122. "176 88 56 0.170923 \n",
  123. "177 95 56 0.133268 \n",
  124. "178 73 56 0.102703 \n",
  125. "179 50 55 0.121086 \n",
  126. "180 61 57 0.112961 \n",
  127. "\n",
  128. "[181 rows x 9 columns]\n"
  129. ]
  130. }
  131. ],
  132. "source": [
  133. "print(sleep_score_df)"
  134. ]
  135. },
  136. {
  137. "cell_type": "markdown",
  138. "metadata": {},
  139. "source": [
  140. "With the Pandas library you can generate Matplotlib graphs.\n",
  141. "Although you can directly use Matplotlib, the wrapper functions using Pandas makes it easier to use.\n",
  142. "\n",
  143. "## Sleep Score Histogram"
  144. ]
  145. },
  146. {
  147. "cell_type": "code",
  148. "execution_count": 3,
  149. "metadata": {},
  150. "outputs": [
  151. {
  152. "data": {
  153. "text/plain": [
  154. "array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7fc2c0a270d0>]],\n",
  155. " dtype=object)"
  156. ]
  157. },
  158. "execution_count": 3,
  159. "metadata": {},
  160. "output_type": "execute_result"
  161. },
  162. {
  163. "data": {
  164. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEICAYAAACgQWTXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAWtUlEQVR4nO3df5BdZ33f8fcH2wTba0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4KfB34VXq/EG5Mcg1wH3D58pQoSRrUQKFeVV8GTjSfs3m45UiSlsJPlEpSQwx1SWqIoS5JDTHUJakhhrokNcRQl6SGGOqS1BBDXZIaYqhLUkMMdUlqiKEuSQ0x1CWpIYa6JDXEUJekhhjqktQQQ12SGmKoS1JDBvrmoyQHgO8DfwMcq6qJJOcC/xXYABwA/llVHVmeMiVJg1jImfpUVV1YVY99rd0OYHdVbQR2d8uSpFW0lOmXLcCu7v4u4LKllyNJWopU1fyNkm8AR4AC/qiqdiY5WlVr+9ocqapzTvDcbcA2gPHx8Yump6fn3Nfs7CxjY2ML60VDRr3/4BhA+2Ow7+Aj87YZPx0OPTrc/W5av2a4G1xG/cfA1NTU3r5ZkjkNNKcOXFxVDyZ5BnBHkq8OWlhV7QR2AkxMTNTk5OSc7WdmZpivTctGvf/gGED7Y3D1jtvnbbN90zGu3zdoRA3mwFWTQ93eclrsMTDQ9EtVPdjdHgZuBl4OHEqyDqC7PbzgvUuShmreUE9yZpKzHrsPvA64C7gV2No12wrcslxFSpIGM8hrm3Hg5iSPtf9EVX06yReBG5NcA9wHXL58ZUqSBjFvqFfV14GXnGD9w8Dm5ShKkrQ4fqJUkhpiqEtSQwx1SWqIoS5
  165. "text/plain": [
  166. "<Figure size 432x288 with 1 Axes>"
  167. ]
  168. },
  169. "metadata": {
  170. "needs_background": "light"
  171. },
  172. "output_type": "display_data"
  173. }
  174. ],
  175. "source": [
  176. "sleep_score_df.hist(column='overall_score')"
  177. ]
  178. },
  179. {
  180. "cell_type": "markdown",
  181. "metadata": {},
  182. "source": [
  183. "## Heart Rate\n",
  184. "\n",
  185. "Fitbit keeps their calculated heart rates in the sleep scores file rather than heart.\n",
  186. "Knowing your resting heart rate is useful because it is a good indicator of your overall health.\n",
  187. "\n",
  188. "![](restingHeartRate.jpg)"
  189. ]
  190. },
  191. {
  192. "cell_type": "code",
  193. "execution_count": 4,
  194. "metadata": {},
  195. "outputs": [
  196. {
  197. "data": {
  198. "text/plain": [
  199. "array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7fc2917a6090>]],\n",
  200. " dtype=object)"
  201. ]
  202. },
  203. "execution_count": 4,
  204. "metadata": {},
  205. "output_type": "execute_result"
  206. },
  207. {
  208. "data": {
  209. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEICAYAAABGaK+TAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAATWklEQVR4nO3df5Dcd33f8ecLKxiPBZYdmauwHV8SDC2DWoIvxpmU5hTXibAd7GkDhQKRExOVTCEwI1oUOpOQdmhFqNOBCdPEEBJNIFEcg7HHhtbGycGQ2IAEGOGYVMQo/oGRDLGMz5gfwu/+sV8119Odbm9vT7sf8XzM7Ox+f+xn3++9+77uu9/97l6qCklSe5406gIkSYMxwCWpUQa4JDXKAJekRhngktQoA1ySGmWAaywkeUWSW1b5MWaSvHo1H0M6ngxwHXdJJpNUkjVH5lXV+6vqZ0ZZ1zAlmU5y/yqOX0meuVrjqw0GuAY2N4D1D1b6vPi8ql8GuJYlyf4kb0ryeeCxJD+U5ANJHkry5SS/OmfdC5LsTvKNJAeS/Ha36OPd9aEks0l+IsmVST4x576V5DVJ9iV5OMm7kqRbdlKSq5N8rXvM187foz+Gc5P8ZZJHk9ySZP2cx7wwyV8lOZTkziTTc5b9YpK7u/vdk+TfzVk2neT+7nn5KvAnwEeAZ3T9zSZ5xjGe07ckuS7J+5J8A7iye+5u72p5MMnvJHlyt/6R5+/Obux/082/LMnnuvv8VZJ/2sfzoZZVlRcvfV+A/cDngHOAU4E9wK8DTwZ+BLgH+Nlu3duBV3W31wIXdrcngQLWzBn3SuATc6YLuAlYB/wQ8BCwuVv2GuCvgbOB04GPzh9vkdpngL8FngWc0k3v6JadBXwduITejs3F3fSZ3fJLgR8FAvwU8E3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aMsCTPCXJp5LcmeSuJL/ZzT8jya1J9nXXp69+uZKkI/rZA/828NNV9c+A5wGbk1wIbAduq6rzgNu6aUnScbJkgFfPbDf5A92lgMuBnd38ncAVq1KhJGlBqaqlV0pOAvYAzwTeVVVvSnKoqtbNWefhqjrqMEqSrcBWgImJifN37do1UKGzs7OsXbt2oPuOm3572fvAI8ehmpWZOAUOPD7qKlZulH1sPOu0oY73/bittGAlvWzatGlPVU3Nn99XgP+/lZN1wPXA64BP9BPgc01NTdXu3bv7r3qOmZkZpqenB7rvuOm3lxbOQtm28TBX723/ZKZR9rF/x6VDHe/7cVtpwUp6SbJggC/rLJSqOgTMAJuBA0k2dINvAA4OVJkkaSD9nIVyZrfnTZJTgH8JfBG4EdjSrbYFuGG1ipQkHa2f14wbgJ3dcfAnAddW1U1JbgeuTXIVcC/wklWsU5I0z5IBXlWfB35sgflfBy5ajaIkSUvzk5iS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1KjDHBJapQBLkmNMsAlqVEGuCQ1ygCXpEYZ4JLUKANckhplgEtSowxwSWqUAS5JjTLAJalRBrgkNcoAl6RGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGmWAS1Kj1oy6gBZMbr95qONt23iYK4c8pqTvP+6BS1KjlgzwJOck+Yskdye5K8nru/lnJLk1yb7u+vTVL1eSdEQ/e+CHgW1V9U+AC4F/n+Q5wHbgtqo6D7itm5YkHSdLBnhVPVhVn+luPwrcDZwFXA7s7FbbCVyxWkVKko6Wqup/5WQS+DjwXODeqlo3Z9nDVXXUYZQkW4GtABMTE+fv2rVroEJnZ2dZu3btQPddqb0PPDLU8SZOgQOPD3XIkTlRehllHxvPOm2o441yWxk2e+nZtGnTnqqamj+
  210. "text/plain": [
  211. "<Figure size 432x288 with 1 Axes>"
  212. ]
  213. },
  214. "metadata": {
  215. "needs_background": "light"
  216. },
  217. "output_type": "display_data"
  218. }
  219. ],
  220. "source": [
  221. "sleep_score_df.hist(column='resting_heart_rate')"
  222. ]
  223. },
  224. {
  225. "cell_type": "markdown",
  226. "metadata": {},
  227. "source": [
  228. "## Resting Heart Rate Time Graph\n",
  229. "\n",
  230. "Using the pandas wrapper we can quickly create a heart rate graph over time."
  231. ]
  232. },
  233. {
  234. "cell_type": "code",
  235. "execution_count": 5,
  236. "metadata": {},
  237. "outputs": [
  238. {
  239. "data": {
  240. "text/plain": [
  241. "<matplotlib.axes._subplots.AxesSubplot at 0x7fc28f609b50>"
  242. ]
  243. },
  244. "execution_count": 5,
  245. "metadata": {},
  246. "output_type": "execute_result"
  247. },
  248. {
  249. "data": {
  250. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAdEAAAEWCAYAAAA5Lq2XAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOy9eZxkVX33//nWequ7qqtmprdqhplhBhhEdkYEVGRxiVFjiCQxUUN8khDNozGJxpj4EH9ZjIr6E5+YqCjBJZpHJGDykICA4AKyzQjIMsw+wExV9/QsVV3VXbfW8/xxz7l169attWvpqv6+X69+dfddzz13+Z7vcr5fEkKAYRiGYZjWcfW7AQzDMAwzqLAQZRiGYZg2YSHKMAzDMG3CQpRhGIZh2oSFKMMwDMO0CQtRhmEYhmkTFqLM0ENEG4goTUTufrdlWCEiPxE9R0TTPT7n80Q02atzMowdFqJM3yCig0SUkQJuloi+TkTBDh33dep/IcSLQoigEKK43GM7nOvrRPT3tmWbiEgQkafT55PH/xER/X6d9er8aflzkIg+2sLxf5eIHmyxWdcB+IkQYlYe4+tElJPnTxHRDiJ6re0cRbl+gYieJKK3yHWXy/bfbmvXuXL5jwBACJEF8C8A/qLFtjJMx2AhyvSbtwohggDOA3A+gL/sc3tWLGTQy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SSGcxENAT95UTzasqLylgEsE+UYYadgRaiRBQhotuI6Hki2klEl1jWfZiIBBGN97ONzPAhhEA8oWN6LFCRmSilF+BxEfwel2nOZZ8owww3nn43YJl8AcDdQohriMgHYAQAiOhkAK8H8GI
  251. "text/plain": [
  252. "<Figure size 432x288 with 1 Axes>"
  253. ]
  254. },
  255. "metadata": {
  256. "needs_background": "light"
  257. },
  258. "output_type": "display_data"
  259. }
  260. ],
  261. "source": [
  262. "sleep_score_df.plot(kind='line', y='resting_heart_rate', x ='timestamp', legend=False, title=\"Resting Heart Rate(BPM)\")"
  263. ]
  264. },
  265. {
  266. "cell_type": "markdown",
  267. "metadata": {},
  268. "source": [
  269. "However, as we notice with the graph above, the time axis is wack.\n",
  270. "In the pandas data frame everything was stored as a string timestamp.\n",
  271. "We can convert this into a datetime object by telling pandas to parse the date as it reads it."
  272. ]
  273. },
  274. {
  275. "cell_type": "code",
  276. "execution_count": 6,
  277. "metadata": {},
  278. "outputs": [
  279. {
  280. "data": {
  281. "text/plain": [
  282. "<matplotlib.axes._subplots.AxesSubplot at 0x7fc28f533510>"
  283. ]
  284. },
  285. "execution_count": 6,
  286. "metadata": {},
  287. "output_type": "execute_result"
  288. },
  289. {
  290. "data": {
  291. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEUCAYAAADN8orUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOydd5hjV3nwf6/KqEzV7MyWKbvrdVl3G7y4ATYG03sCSYAQSsAhxd8HDi20QICEmgSSUEwx5aMbTAgQY1MMNritcW/YXts7M9t3ijQjadTO98e95+pKI2mkGbXRnN/z7LOjes/Rvfe85+2ilMJgMBgM6xNPqwdgMBgMhtZhhIDBYDCsY4wQMBgMhnWMEQIGg8GwjjFCwGAwGNY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5g3icQK/IJdPk8TJowUUOdMULAYGgToskMfSEf4S4vHsk7hrUmsHNTr9EEDHXHCAGDoQ1QSjnmIBGhJ+BzhYha/+/c3Gt8Aoa6Y4SAwdAGxFNZMjlFX9DyB/QG/QXRQd1dXrYOhjkyv0gynW3lUA0dRlOEgIgMiMiVIvKAiNwvIue5XnuriCgRGWrGWAyGdkRHAvWFtBDwOd3Fook0vUE/o3Ym8T7jFzDUkWZpAp8CrlZKnQicAdwPICLjwDOBvU0ah8HQlkQT1oLf7xYCrozhvpCP0YglBEwNIUM9abgQEJE+4ALgSwBKqZRSatZ++d+AtwOqzMcNhnWBriBa0hy0WKgJGOewoZ40QxPYARwGrhCR20XkiyLSLSIvAqaUUndW+rCIXCIiu0Vk9+HDh5swXIOh+RyIJgGroQzAcE+Ag/Zz0USG3qDPee3oQqo1gzR0JM0
  292. "text/plain": [
  293. "<Figure size 432x288 with 1 Axes>"
  294. ]
  295. },
  296. "metadata": {
  297. "needs_background": "light"
  298. },
  299. "output_type": "display_data"
  300. }
  301. ],
  302. "source": [
  303. "sleep_score_df = pd.read_csv('data/sleep/sleep_score.csv', parse_dates=[1])\n",
  304. "sleep_score_df.plot(kind='line', y='resting_heart_rate', x ='timestamp', legend=False, title=\"Resting Heart Rate(BPM)\")"
  305. ]
  306. },
  307. {
  308. "cell_type": "markdown",
  309. "metadata": {},
  310. "source": [
  311. "To fully manipulate the graphs, we need to use some matplotlib code to do things like setting the axis labels or make multiple plots right next to each other.\n",
  312. "We can create grab the current axis being used by matplotlib by using plt.gca()."
  313. ]
  314. },
  315. {
  316. "cell_type": "code",
  317. "execution_count": 7,
  318. "metadata": {},
  319. "outputs": [
  320. {
  321. "data": {
  322. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAl4AAAFFCAYAAAA92ONDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0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gNJFQNJH9PxyTOC9BuNAQ4SUIgtBEQiaxtSgB9oJwwSHCSxAEoYksiKtREC5oRHgJgiA0kXAsgYDfbfwvFi9BuNAQ4SUIgtBEQlENuwa9INJLSgiCcGEhwksQBKGJhGIaAj1d6O12ShFVQbgAEeElCILQRBaiCQx4XejzuLAoMV6CcMEhwksQBKFJJFJpRFZTuvDyurAoMV6CcMEhwksQBKFJLMZ0C9eAz40+j1MsXoJwASLCSxAEoUksGMVTB3yGq1EsXoJwwSHCSxAEoUmo4qmDPsPVaDTKFgThwkGElyAIQpNQ7YL6vW70eVxIpDJYSaYLPvdH0/P4wiOnmjk8QRCagAgvQRCEJqEaZOuuRicAFI3zuuunx/F33z7YtLEJgtAcRHgJgiA0iVBMg8tug9/tQK/HBQBF47zCMQ2hmLamqbYgCJ2PCC9BEIQmEYomMOBzgYjQ7zWEV5Eiqqqd0OG5aNPGJwhC4xHhJQiC0CRCMQ0DPl1wlXM1KkvY4XkRXoKwkRDhJQiC0CRC0QT6vXqD7D5vcVdjIpVGJJECAMwERXgJwkZChJcgCEKTWIhqGDQEV2+3snitF15LJiuYuBoFYWMhwksQBKFJhE2uRofdhp4uR0GLl4rv8rkdIrwEYYMhwksQBKEJxLUUVpJpDPjc2W16EdX1MV5KeO0b7cPs8iqWV6W1kCBsFER4CYIgNIF
  323. "text/plain": [
  324. "<Figure size 720x360 with 1 Axes>"
  325. ]
  326. },
  327. "metadata": {
  328. "needs_background": "light"
  329. },
  330. "output_type": "display_data"
  331. }
  332. ],
  333. "source": [
  334. "ax = plt.gca()\n",
  335. "sleep_score_df.plot(kind='line', y='resting_heart_rate', x ='timestamp', legend=False, title=\"Resting Heart Rate Graph\", ax=ax, figsize=(10, 5))\n",
  336. "plt.xlabel(\"Date\")\n",
  337. "plt.ylabel(\"Resting Heart Rate (BPM)\")\n",
  338. "plt.show()\n",
  339. "#plt.savefig('restingHeartRate.svg')"
  340. ]
  341. },
  342. {
  343. "cell_type": "markdown",
  344. "metadata": {},
  345. "source": [
  346. "The same thing can be done with sleep scores.\n",
  347. "It is interesting to note that the sleep scores rarely vary anything between 75 and 85."
  348. ]
  349. },
  350. {
  351. "cell_type": "code",
  352. "execution_count": 8,
  353. "metadata": {},
  354. "outputs": [
  355. {
  356. "data": {
  357. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEUCAYAAADN8orUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOy9Z5gkV3k2fJ9KnSeH3Z3NSStpJYS0yiCEJJLgRXqNwfgzfAjbYILBvMZEk4PRh22yQZYRr7ANIgsw2AihnKVVXmm1OYfJM527q6rP9+OEOtVd3dM92z1ht+/rmmu3U9WpU6fO8zz3kwilFG200UYbbZya0OZ7AG200UYbbcwf2kKgjTbaaOMURlsItNFGG22cwmgLgTbaaKONUxhtIdBGG220cQqjLQTaaKONNk5htIXAKQpCyHWEkPvnexyLAYSQ5wghl8/3OBoFIeQGQsgn53scJwpCyOWEkMPzPY6TFW0hcBKDEPISQsiDhJBpQsgEIeQBQsj58zymMwkhvyeETBJCpgghjxNCrp7H8fwZISTN/3KEkJLyOg0AlNIzKaV3z8FYuggh3yOEHCeEpAghOwkhH5nt8Sil76KUfr6ZYwQAQsgWQshvlHv4PCHki4SQ7mafq43Woy0ETlIQQjoA/AbANwH0ABgC8FkAhfkcF4D/AnA7gEEAAwDeDyDZzBMQQox6v0sp/QGlNE4pjQN4DYCj4jV/by7xVQBxAKcD6ATwegB7ZnMgQojexHGpx70EwN0AHgCwiVLaBeDVABwAL6rym7rvRxvzAEpp++8k/AOwBcBUjc+vA3C/8noT2OY8AWAHgDcpn4UA/BOAgwCGAdwAIMI/uxzAYQAfBzAGYD+AP6tyzj4AFEBXjXFdA+ApMMGwB8Cr+fvLAPyaj283gHcov/k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G6cw2nRQG2200cYpjDmxBAghf0MI2UZYNcYP8Pd6CCG3E0J28X/bxafaaKONNuYYLbcECCGbAfwIrCRAESyS4N1gkQoTlNLrCSEfBUsBr1kxsa+vj65evbql422jjTbaONnw+OOPj1FK+4M+m4vqfqcDeJhSmgUAQsg9AP43WKGwy/l3vg8WYlZTCKxevRpbt25t2UDbaKONNk5GEEIOVPtsLuigbQAuI4T0EkKiYDVBVoDVsDkGyKSawFR6Qsg7CSFbCSFbR0dH52C4bbTRRhunDlouBCil28GSWm4Ho4KeBis4Vu/vb6SUbqGUbunvD7Rm2mijjTbamCXmxDFMKb2JUnoupfQysPriuwAME0KWAgD/d2QuxtJGG2200YaHuYoOEjVGVoIVn7oFLKX/bfwrbwPwq7kYSxtttNFGGx7mqu3bzwkhvWA10t9LKZ0khFwP4CeEkL8A61j1xjkaSxtttNFGGxxzIgQopS8NeG8cwJVzcf422mijjTaC0W4A3UYbiwyOW8J/PHwA6byDzqiJt1y4CppWXpq/jZMJpRLFrU8ewTXnLIOhN5fFbwuBNtpYZHjy0BQ++1/Py9cvXtGNs5Z3zuOI2mg1Ht47jg/+9Gn0JUJ42cbmRkm2C8i10cYiw1iqAAD48hvOBgAcmcrO53DamAMcnGD3eDJTbPqx20KgjTYWGcb5RnD2Cqb9H5nKz+dw2pgDHJ5kraunsm0h0MZJiof2jOPmB/bN9zAWBYQ2uLYvjrCp4egU2yD+6+mj+PXTc9uWN11w8KlfbcN0zp7T8y50jCTz+NSvtiFdqDsvtiYOTzJLYKoF89wWAm0sCPzosYP41l175nsYiwLjmSISIQOWoWFZV0QKgW/euQs33bd3Tsdy/64x/PtDB/DQnvE5Pe9Cx/272bz8x0NVS/Y0BGEJtELYtoVAGwsC4+ki3FJpvoexKDCRKaInbgEAhroiODqdh+OWsG8sM+ca+Z7RNABgNF2Y0/M
  358. "text/plain": [
  359. "<Figure size 432x288 with 1 Axes>"
  360. ]
  361. },
  362. "metadata": {
  363. "needs_background": "light"
  364. },
  365. "output_type": "display_data"
  366. }
  367. ],
  368. "source": [
  369. "ax = plt.gca()\n",
  370. "sleep_score_df.plot(kind='line', y='overall_score', x ='timestamp', legend=False, title=\"Sleep Score Time Series Graph\", ax=ax)\n",
  371. "plt.xlabel(\"Date\")\n",
  372. "plt.ylabel(\"Fitbit's Sleep Score\")\n",
  373. "plt.show()"
  374. ]
  375. },
  376. {
  377. "cell_type": "markdown",
  378. "metadata": {},
  379. "source": [
  380. "Using Pandas we can generate a new column with a specific date attribute like year, day, month, or weekday.\n",
  381. "If we add a new column for weekday, we can then group by weekday and collapse them all into a single column by summing or averaging the value."
  382. ]
  383. },
  384. {
  385. "cell_type": "code",
  386. "execution_count": 9,
  387. "metadata": {},
  388. "outputs": [
  389. {
  390. "name": "stdout",
  391. "output_type": "stream",
  392. "text": [
  393. " sleep_log_entry_id timestamp overall_score \\\n",
  394. "0 26093459526 2020-02-27 06:04:30+00:00 80 \n",
  395. "1 26081303207 2020-02-26 06:13:30+00:00 83 \n",
  396. "2 26062481322 2020-02-25 06:00:30+00:00 82 \n",
  397. "3 26045941555 2020-02-24 05:49:30+00:00 79 \n",
  398. "4 26034268762 2020-02-23 08:35:30+00:00 75 \n",
  399. ".. ... ... ... \n",
  400. "176 23696231032 2019-09-02 07:38:30+00:00 79 \n",
  401. "177 23684345925 2019-09-01 07:15:30+00:00 84 \n",
  402. "178 23673204871 2019-08-31 07:11:00+00:00 74 \n",
  403. "179 23661278483 2019-08-30 06:34:00+00:00 73 \n",
  404. "180 23646265400 2019-08-29 05:55:00+00:00 80 \n",
  405. "\n",
  406. " composition_score revitalization_score duration_score \\\n",
  407. "0 20 19 41 \n",
  408. "1 22 21 40 \n",
  409. "2 22 21 39 \n",
  410. "3 17 20 42 \n",
  411. "4 20 16 39 \n",
  412. ".. ... ... ... \n",
  413. "176 20 20 39 \n",
  414. "177 22 21 41 \n",
  415. "178 18 21 35 \n",
  416. "179 17 19 37 \n",
  417. "180 21 21 38 \n",
  418. "\n",
  419. " deep_sleep_in_minutes resting_heart_rate restlessness weekday \n",
  420. "0 65 60 0.117330 3 \n",
  421. "1 85 60 0.113188 2 \n",
  422. "2 95 60 0.120635 1 \n",
  423. "3 52 61 0.111224 0 \n",
  424. "4 43 59 0.154774 6 \n",
  425. ".. ... ... ... ... \n",
  426. "176 88 56 0.170923 0 \n",
  427. "177 95 56 0.133268 6 \n",
  428. "178 73 56 0.102703 5 \n",
  429. "179 50 55 0.121086 4 \n",
  430. "180 61 57 0.112961 3 \n",
  431. "\n",
  432. "[181 rows x 10 columns]\n"
  433. ]
  434. }
  435. ],
  436. "source": [
  437. "temp = pd.DatetimeIndex(sleep_score_df['timestamp'])\n",
  438. "sleep_score_df['weekday'] = temp.weekday\n",
  439. "\n",
  440. "print(sleep_score_df)"
  441. ]
  442. },
  443. {
  444. "cell_type": "code",
  445. "execution_count": 10,
  446. "metadata": {},
  447. "outputs": [
  448. {
  449. "name": "stdout",
  450. "output_type": "stream",
  451. "text": [
  452. " sleep_log_entry_id overall_score composition_score \\\n",
  453. "weekday \n",
  454. "0 2.483733e+10 79.576923 20.269231 \n",
  455. "1 2.485200e+10 77.423077 20.423077 \n",
  456. "2 2.490383e+10 80.880000 21.120000 \n",
  457. "3 2.483418e+10 76.814815 20.370370 \n",
  458. "4 2.480085e+10 79.769231 20.961538 \n",
  459. "5 2.477002e+10 78.840000 20.520000 \n",
  460. "6 2.482581e+10 77.230769 20.269231 \n",
  461. "\n",
  462. " revitalization_score duration_score deep_sleep_in_minutes \\\n",
  463. "weekday \n",
  464. "0 19.153846 40.153846 88.000000 \n",
  465. "1 19.000000 38.000000 83.846154 \n",
  466. "2 19.400000 40.360000 93.760000 \n",
  467. "3 19.037037 37.407407 82.592593 \n",
  468. "4 19.346154 39.461538 94.461538 \n",
  469. "5 19.080000 39.240000 93.720000 \n",
  470. "6 18.269231 38.692308 89.423077 \n",
  471. "\n",
  472. " resting_heart_rate restlessness \n",
  473. "weekday \n",
  474. "0 58.576923 0.139440 \n",
  475. "1 58.538462 0.142984 \n",
  476. "2 58.560000 0.138661 \n",
  477. "3 58.333333 0.135819 \n",
  478. "4 58.269231 0.129791 \n",
  479. "5 58.080000 0.138315 \n",
  480. "6 58.153846 0.147171 \n"
  481. ]
  482. }
  483. ],
  484. "source": [
  485. "print(sleep_score_df.groupby('weekday').mean())"
  486. ]
  487. },
  488. {
  489. "cell_type": "markdown",
  490. "metadata": {},
  491. "source": [
  492. "## Sleep Score Based on Day"
  493. ]
  494. },
  495. {
  496. "cell_type": "code",
  497. "execution_count": 11,
  498. "metadata": {},
  499. "outputs": [
  500. {
  501. "data": {
  502. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEWCAYAAACXGLsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOydZ3hc1bWw36VeLMsqI/cuS+5VNhhjywXbGEINYJNKcgkkVEPCDdybBPjSuAk1hRCSUBISbEMwzQJMiRsGLLnKTe62ZEmW5CLJstXX9+OcMYMYSSNrmqT9Ps88mrPPLuvMaM46e+211xJVxWAwGAyGlggJtAAGg8FgCH6MsjAYDAZDqxhlYTAYDIZWMcrCYDAYDK1ilIXBYDAYWsUoC4PBYDC0ilEWHRARuUlE1gVaDoNvEJHpIpIXaDkCiYj8QkTKRKQ4wHK8ICK/CKQMwYJRFkGKiFwsIutFpFxETojIxyIyOcAyjRKRlSJyUkROichGEbkskDL5GhGJsq91tptzT4jIq94eU1XXqmq6t/sFEJFVIlItIpUiUmF/h/eLSKQvxjsfRKQ/8ENgpKr2cnM+T0RucDmeJiLqpuy0iIT5R+rOj1EWQYiIdAfeBn4PJAJ9gYeBmkDKBbwFvA/0BFKAu4AKbw4QbD9uVa0GlgLfci0XkVDgRuDFtvYZBNd4h6rGAb2xbsqLgCwRkcCKdY6BwHFVLWnm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RvpLVYDAYDC3jazNUGBAtInVYMYoKVXUXQCsRfqdgxd45YNd1Bgjb6VtxDQaDweAOn80sVPUo8ChwBCt+TbmqrvSweV++GBC
  503. "text/plain": [
  504. "<Figure size 432x288 with 1 Axes>"
  505. ]
  506. },
  507. "metadata": {
  508. "needs_background": "light"
  509. },
  510. "output_type": "display_data"
  511. }
  512. ],
  513. "source": [
  514. "ax = plt.gca()\n",
  515. "sleep_score_df.groupby('weekday').mean().plot(kind='line', y='overall_score', ax = ax)\n",
  516. "plt.ylabel(\"Sleep Score\")\n",
  517. "plt.title(\"Sleep Scores on Varying Days of Week\")\n",
  518. "plt.show()"
  519. ]
  520. },
  521. {
  522. "cell_type": "markdown",
  523. "metadata": {},
  524. "source": [
  525. "## Sleep Score Based on Days of Week"
  526. ]
  527. },
  528. {
  529. "cell_type": "code",
  530. "execution_count": 12,
  531. "metadata": {},
  532. "outputs": [
  533. {
  534. "data": {
  535. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEWCAYAAACXGLsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3dd3hUddbA8e9JI5BAAklooYYiTbqKVEGKIIJdcXUtq+y62NfdtbwqdldRV8WOix0VFSsiKNIEREAQpBNCEYTQCS0hOe8f9waHmDKBmdzM5HyeZ57cuXPLuZNkzvzqFVXFGGOMKU6E1wEYY4wp/yxZGGOMKZElC2OMMSWyZGGMMaZEliyMMcaUyJKFMcaYElmyCGMi0kBEskQk0utYTOCJyF0iMsbrOLwiIpVF5HMR2SMi4z2OJUNE+noZQ7BZsvCA+4d10P0g/01EXheR+AAd9+gfrKpuUNV4Vc090WMXcq7XReShAusaiYiKSFSgz+cef5qIXFvM6/nnz3IfGSJyRymOf5WIzDrO2E4Xkf0iUrWQ134S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f/VVwtFdEdkkHTk5O1kaNGgUqTmOMCXsLFizYrqrFDTQFgl+yWIfTzUyBl1X1FXEmbPsapw9/BNBVVdcX2K89TqPYMpw5bhbgTCPwh26DIjIcGA7QoEGDTuvXry+4iTHGmCKIyAJV7VzSdsFu4O6mqh1x+kmPEJGeODNX3qqq9XHmZnmtkP2icAbzvKiqHXAG5hQ6rYWqvqKqnVW1c0pKicnRGGPMcQhqsnD
  536. "text/plain": [
  537. "<Figure size 432x288 with 1 Axes>"
  538. ]
  539. },
  540. "metadata": {
  541. "needs_background": "light"
  542. },
  543. "output_type": "display_data"
  544. }
  545. ],
  546. "source": [
  547. "ax = plt.gca()\n",
  548. "sleep_score_df.groupby('weekday').mean().plot(kind='line', y='resting_heart_rate', ax = ax)\n",
  549. "plt.ylabel(\"Resting heart rate (BPM)\")\n",
  550. "plt.title(\"Resting Heart Rate Varying Days of Week\")\n",
  551. "plt.show()"
  552. ]
  553. },
  554. {
  555. "cell_type": "markdown",
  556. "metadata": {},
  557. "source": [
  558. "# Calories\n",
  559. "\n",
  560. "Fitbit keeps all of their calorie data in JSON files representing sequence data at 1 minute increments.\n",
  561. "To extrapolate calorie data we need to group by day and then sum the days to get the total calories burned per day."
  562. ]
  563. },
  564. {
  565. "cell_type": "code",
  566. "execution_count": 13,
  567. "metadata": {},
  568. "outputs": [],
  569. "source": [
  570. "calories_df = pd.read_json(\"data/calories/calories-2019-07-01.json\", convert_dates=True)"
  571. ]
  572. },
  573. {
  574. "cell_type": "code",
  575. "execution_count": 14,
  576. "metadata": {},
  577. "outputs": [
  578. {
  579. "name": "stdout",
  580. "output_type": "stream",
  581. "text": [
  582. " dateTime value\n",
  583. "0 2019-07-01 00:00:00 1.07\n",
  584. "1 2019-07-01 00:01:00 1.07\n",
  585. "2 2019-07-01 00:02:00 1.07\n",
  586. "3 2019-07-01 00:03:00 1.07\n",
  587. "4 2019-07-01 00:04:00 1.07\n",
  588. "... ... ...\n",
  589. "43195 2019-07-30 23:55:00 1.07\n",
  590. "43196 2019-07-30 23:56:00 1.07\n",
  591. "43197 2019-07-30 23:57:00 1.07\n",
  592. "43198 2019-07-30 23:58:00 1.07\n",
  593. "43199 2019-07-30 23:59:00 1.07\n",
  594. "\n",
  595. "[43200 rows x 2 columns]\n"
  596. ]
  597. }
  598. ],
  599. "source": [
  600. "print(calories_df)"
  601. ]
  602. },
  603. {
  604. "cell_type": "code",
  605. "execution_count": 15,
  606. "metadata": {},
  607. "outputs": [
  608. {
  609. "name": "stdout",
  610. "output_type": "stream",
  611. "text": [
  612. " dateTime value date_minus_time\n",
  613. "date_minus_time \n",
  614. "2019-07-01 2019-07-01 00:00:00 1.07 2019-07-01\n",
  615. "2019-07-01 2019-07-01 00:01:00 1.07 2019-07-01\n",
  616. "2019-07-01 2019-07-01 00:02:00 1.07 2019-07-01\n",
  617. "2019-07-01 2019-07-01 00:03:00 1.07 2019-07-01\n",
  618. "2019-07-01 2019-07-01 00:04:00 1.07 2019-07-01\n",
  619. "... ... ... ...\n",
  620. "2019-07-30 2019-07-30 23:55:00 1.07 2019-07-30\n",
  621. "2019-07-30 2019-07-30 23:56:00 1.07 2019-07-30\n",
  622. "2019-07-30 2019-07-30 23:57:00 1.07 2019-07-30\n",
  623. "2019-07-30 2019-07-30 23:58:00 1.07 2019-07-30\n",
  624. "2019-07-30 2019-07-30 23:59:00 1.07 2019-07-30\n",
  625. "\n",
  626. "[43200 rows x 3 columns]\n"
  627. ]
  628. }
  629. ],
  630. "source": [
  631. "import datetime\n",
  632. "calories_df['date_minus_time'] = calories_df[\"dateTime\"].apply( lambda calories_df : \n",
  633. " datetime.datetime(year=calories_df.year, month=calories_df.month, day=calories_df.day))\t\n",
  634. "\n",
  635. "calories_df.set_index(calories_df[\"date_minus_time\"],inplace=True)\n",
  636. "\n",
  637. "print(calories_df)"
  638. ]
  639. },
  640. {
  641. "cell_type": "code",
  642. "execution_count": 16,
  643. "metadata": {},
  644. "outputs": [
  645. {
  646. "name": "stdout",
  647. "output_type": "stream",
  648. "text": [
  649. " value\n",
  650. "date_minus_time \n",
  651. "2019-07-01 3422.68\n",
  652. "2019-07-02 2705.85\n",
  653. "2019-07-03 2871.73\n",
  654. "2019-07-04 4089.93\n",
  655. "2019-07-05 3917.91\n",
  656. "2019-07-06 2762.55\n",
  657. "2019-07-07 2929.58\n",
  658. "2019-07-08 2698.99\n",
  659. "2019-07-09 2833.27\n",
  660. "2019-07-10 2529.21\n",
  661. "2019-07-11 2634.25\n",
  662. "2019-07-12 2953.91\n",
  663. "2019-07-13 4247.45\n",
  664. "2019-07-14 2998.35\n",
  665. "2019-07-15 2846.18\n",
  666. "2019-07-16 3084.39\n",
  667. "2019-07-17 2331.06\n",
  668. "2019-07-18 2849.20\n",
  669. "2019-07-19 2071.63\n",
  670. "2019-07-20 2746.25\n",
  671. "2019-07-21 2562.11\n",
  672. "2019-07-22 1892.99\n",
  673. "2019-07-23 2372.89\n",
  674. "2019-07-24 2320.42\n",
  675. "2019-07-25 2140.87\n",
  676. "2019-07-26 2430.38\n",
  677. "2019-07-27 3769.04\n",
  678. "2019-07-28 2036.24\n",
  679. "2019-07-29 2814.87\n",
  680. "2019-07-30 2077.82\n"
  681. ]
  682. }
  683. ],
  684. "source": [
  685. "calories_per_day = calories_df.resample('D').sum()\n",
  686. "print(calories_per_day)"
  687. ]
  688. },
  689. {
  690. "cell_type": "code",
  691. "execution_count": 17,
  692. "metadata": {},
  693. "outputs": [
  694. {
  695. "data": {
  696. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEICAYAAABVv+9nAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAUf0lEQVR4nO3de5gldX3n8fdHGAUEZIVWEWha1GCIGwFbDauJEY3hFtR9XIPB626cdSNZXWOSQY3BuBj0WRUNRh0TEuUSN14wB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7f9CTJ04F7ZlhekrTIRh2DfxPw6STruuf7Ar/eT0mSpIUwUsBX1deTPAU4GAhwTVX9ZJR1k+wErAJuqqrjtrpSSdKcjHoGD/AMYKJb57AkVNUnR1jvjQyun99z7uVJkrbWSAGf5CzgicCVwMZudgEzBnyS/YFjgVOBN299mZKkuRr1DH4SOKSqao7tnw78HrDHdAskWQ4sBxgfH59j8w+aWHHhVq87H2tPO3ZR+oXF22ZJO4ZRr6K5CnjcXBpOchxwa1Wtnmm5qlpZVZNVNTk2NjaXLiRJMxj1DH4f4DtJLgfu3TSzqo6fYZ1nA8cnOQbYBdgzydlV9YqtrlaSNLJRA/6UuTZcVScDJwMk+WXgLYa7JG07o14meUmSA4EnV9WXk+wG7NRvaZKk+Rj1dsGvAz4DfKybtR/w+VE7qaqLvQZekratUT9kfQODMfX18MCPfzymr6IkSfM3asDfW1X3bXqSZGcG18FLkrZTowb8JUneCuza/Rbrp4G/7a8sSdJ8jRrwK4DbgG8D/xn4AoPfZ5Ukbad
  697. "text/plain": [
  698. "<Figure size 432x288 with 1 Axes>"
  699. ]
  700. },
  701. "metadata": {
  702. "needs_background": "light"
  703. },
  704. "output_type": "display_data"
  705. }
  706. ],
  707. "source": [
  708. "ax = plt.gca()\n",
  709. "calories_per_day.plot(kind='hist', title=\"Calorie Distribution\", legend=False, ax=ax)\n",
  710. "plt.show()"
  711. ]
  712. },
  713. {
  714. "cell_type": "code",
  715. "execution_count": 18,
  716. "metadata": {},
  717. "outputs": [
  718. {
  719. "data": {
  720. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAE5CAYAAABh4gz1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOy9eXhkZZm4fT9V2ZfK3kklaeh9SdPN1iIIAm4DAgoqMLiwqAO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5+zezdF4pJzSUTfEK5ybGGNqCoTHnNkBVcR65XtFcC0WJg2uahTHmJmNMozFmAVHH9d+NMR8AHgSutna7GnjAev4gcIWI5IvIQqKO7OctU1WviJxuRUFdFXNM1mKHzXo8EwdujXd4d6tzdUo4PDDC8GjkKDOUxyPU+gpo7VEzlKJMxnTkWXwdeJuI7ALeZr3GGLMFuA/YCvwZuMEYE7aOuZ6ok3w3sAd4eKoXnSqtPaFj/BXjqS7J50dXnmo5vF9Sh/cUYDux68qONg/6NYtbUeIyJcLCGPO4MeYi63mXMeYtxpil1t/umP1uMcYsNsYsN8Y8HDO+wRhzgrXt41ZUVFbTEhgcy7GIx5rGcv7rXat5Zk8XX1eHt+vY2dvjhUVdWaH6LBQlDprB7QKRiKE9GMJfHl+zsLnUcnj/5Ol9PLS51eXVzW3GJ+TZ1FuaxQy4D1GUaUGFhQt09g0xEjZHRdwk4gsXrqSxopDf/+OgiytTWgMhRKCm9OjAg7qyAoZHIxweGJmmlSlKdqPCwgVa7LDZBD6LWHK9HhbXlNCisf6u0h4IUV2ST6736J++Ldh
  721. "text/plain": [
  722. "<Figure size 432x288 with 1 Axes>"
  723. ]
  724. },
  725. "metadata": {
  726. "needs_background": "light"
  727. },
  728. "output_type": "display_data"
  729. }
  730. ],
  731. "source": [
  732. "ax = plt.gca()\n",
  733. "calories_per_day.plot(kind='line', y='value', legend=False, title=\"Calories Per Day\", ax=ax)\n",
  734. "plt.xlabel(\"Date\")\n",
  735. "plt.ylabel(\"Calories\")\n",
  736. "plt.show()"
  737. ]
  738. },
  739. {
  740. "cell_type": "markdown",
  741. "metadata": {},
  742. "source": [
  743. "## Calories Per Day Box Plot\n",
  744. "\n",
  745. "Using this data we can turn this into a boxplot to make it easier to visualize the distribution of calories burned during the month of July."
  746. ]
  747. },
  748. {
  749. "cell_type": "code",
  750. "execution_count": 19,
  751. "metadata": {},
  752. "outputs": [
  753. {
  754. "data": {
  755. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAA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A54B27dpx7bXXcu+996atz3379jF58mSdfBOphQI4RxQWFlJSUkJ5eXla+luyZAmdO3fm3HPPTUt/Io2RAjhH9O7dm3bt2vH444+npb/i4mJd9UzkMBTAOSRdX0l79dVXeeedd9JyAXqRxkwBnENuuukm1qxZwzvvvJPSfoqLixk3bhzNmjVLaT8ijZ0COIe0bNmSMWPGUFJSkrI+tm7dysKFCxk7dmzK+hDJFgrgHDN+/HhmzZrFrl27UtL+fffdx8CBAzn55JNT0r5INlEA55iOHTvy9a9/nblz5ya97QMHDujkm0g9KIBzUMXJuGTfsuipp56iVatWXHLJJUltVyRbKYBz0GWXXcaXX37JihUrktpuUVERhYWFuuWQSB0pgHNQKm5ZtH79elauXMm3v/3tpLUpku0UwDlq5MiRPPnkk2zcuDEp7ZWWljJy5EhatWqVlPZEcoECOEe1adOGoUOHMmXKlCNua8+ePdx7771MmDAhCZWJ5A4FcA4rKChgypQpfPnll0fUzsKFC+nduzedO3dOUmUiuUEBnMO6d+/OOeecw+LFixvchrsfPPkmIvWjAM5xR3p9iFWrVrFlyxYGDhyYxKpEcoMCOMcNHjyYDz74gJdffrlB8xcVFZGfn69bDok0gF41Oa5p06aMHz++Qbcs+uSTT3jkkUf4zne+k4LKRLKfAlgYO3YsDzzwAFu2bKnXfNOmTeOGG27g+OOPT1FlItlNASyceOKJXH311cycObPO8+zfv5/S0lLdckjkCCiABYh
  756. "text/plain": [
  757. "<Figure size 432x288 with 1 Axes>"
  758. ]
  759. },
  760. "metadata": {
  761. "needs_background": "light"
  762. },
  763. "output_type": "display_data"
  764. }
  765. ],
  766. "source": [
  767. "ax = plt.gca()\n",
  768. "ax.set_title('Calorie Distribution for July')\n",
  769. "ax.boxplot(calories_per_day['value'], vert=False,manage_ticks=False, notch=True)\n",
  770. "plt.xlabel(\"Calories Burned\")\n",
  771. "ax.set_yticks([])\n",
  772. "plt.show()"
  773. ]
  774. },
  775. {
  776. "cell_type": "markdown",
  777. "metadata": {},
  778. "source": [
  779. "# Steps\n",
  780. "\n",
  781. "Fitbit is known for taking the amount of steps someone takes per day.\n",
  782. "Similar to calories burned, steps taken is stored in time series data at 1 minute increments.\n",
  783. "Since we are interested at the day level data, we need to first remove the time component of the dataframe so that we can group all the data by date.\n",
  784. "Once we have everything grouped by date, we can sum and produce steps per day. "
  785. ]
  786. },
  787. {
  788. "cell_type": "code",
  789. "execution_count": 20,
  790. "metadata": {},
  791. "outputs": [
  792. {
  793. "name": "stdout",
  794. "output_type": "stream",
  795. "text": [
  796. " dateTime value date_minus_time\n",
  797. "date_minus_time \n",
  798. "2019-07-01 2019-07-01 04:00:00 0 2019-07-01\n",
  799. "2019-07-01 2019-07-01 04:01:00 0 2019-07-01\n",
  800. "2019-07-01 2019-07-01 04:02:00 0 2019-07-01\n",
  801. "2019-07-01 2019-07-01 04:03:00 0 2019-07-01\n",
  802. "2019-07-01 2019-07-01 04:04:00 0 2019-07-01\n",
  803. "... ... ... ...\n",
  804. "2019-07-31 2019-07-31 03:55:00 0 2019-07-31\n",
  805. "2019-07-31 2019-07-31 03:56:00 0 2019-07-31\n",
  806. "2019-07-31 2019-07-31 03:57:00 0 2019-07-31\n",
  807. "2019-07-31 2019-07-31 03:58:00 0 2019-07-31\n",
  808. "2019-07-31 2019-07-31 03:59:00 0 2019-07-31\n",
  809. "\n",
  810. "[41116 rows x 3 columns]\n"
  811. ]
  812. }
  813. ],
  814. "source": [
  815. "steps_df = pd.read_json(\"data/steps-2019-07-01.json\", convert_dates=True)\n",
  816. "\n",
  817. "steps_df['date_minus_time'] = steps_df[\"dateTime\"].apply( lambda steps_df : \n",
  818. " datetime.datetime(year=steps_df.year, month=steps_df.month, day=steps_df.day))\t\n",
  819. "\n",
  820. "steps_df.set_index(steps_df[\"date_minus_time\"],inplace=True)\n",
  821. "print(steps_df)"
  822. ]
  823. },
  824. {
  825. "cell_type": "code",
  826. "execution_count": 21,
  827. "metadata": {},
  828. "outputs": [
  829. {
  830. "name": "stdout",
  831. "output_type": "stream",
  832. "text": [
  833. " value\n",
  834. "date_minus_time \n",
  835. "2019-07-01 11285\n",
  836. "2019-07-02 4957\n",
  837. "2019-07-03 13119\n",
  838. "2019-07-04 16034\n",
  839. "2019-07-05 11634\n",
  840. "2019-07-06 6860\n",
  841. "2019-07-07 3758\n",
  842. "2019-07-08 9130\n",
  843. "2019-07-09 10960\n",
  844. "2019-07-10 7012\n",
  845. "2019-07-11 5420\n",
  846. "2019-07-12 4051\n",
  847. "2019-07-13 15980\n",
  848. "2019-07-14 23109\n",
  849. "2019-07-15 11247\n",
  850. "2019-07-16 10170\n",
  851. "2019-07-17 4905\n",
  852. "2019-07-18 10769\n",
  853. "2019-07-19 4504\n",
  854. "2019-07-20 5032\n",
  855. "2019-07-21 8953\n",
  856. "2019-07-22 2200\n",
  857. "2019-07-23 9392\n",
  858. "2019-07-24 5666\n",
  859. "2019-07-25 5016\n",
  860. "2019-07-26 5879\n",
  861. "2019-07-27 19492\n",
  862. "2019-07-28 4987\n",
  863. "2019-07-29 9943\n",
  864. "2019-07-30 3897\n",
  865. "2019-07-31 166\n"
  866. ]
  867. }
  868. ],
  869. "source": [
  870. "steps_per_day = steps_df.resample('D').sum()\n",
  871. "print(steps_per_day)"
  872. ]
  873. },
  874. {
  875. "cell_type": "markdown",
  876. "metadata": {},
  877. "source": [
  878. "## Steps Per Day Histogram\n",
  879. "\n",
  880. "After the data is in the form that we want, graphing the data is straight forward.\n",
  881. "Two added things I like to do for normal box plots is to set the displays to horizontal add the notches. "
  882. ]
  883. },
  884. {
  885. "cell_type": "code",
  886. "execution_count": 22,
  887. "metadata": {},
  888. "outputs": [
  889. {
  890. "data": {
  891. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAEWCAYAAABYGk2QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAeA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5OWzYsCEl/TnniMVimv2KpJgCOA3VXqoyFZ5++mnOnDnD6NGjU9KfiAQUwGnqG9/4Bq+//jpbt25Nel/RaJSioiItOSmSYgrgNNWmTRvmzp2b9Fnwtm3bOHDgABMnTkxqPyLyUQrgNPatb32L559/nldffTVpfUSjUQoKCmjbtm3S+hCR+imA01iHDh24++67WbhwYVLa37dvH5s3byYvLy8p7YtI4xTAaW7WrFmsW7eOQ4cOJbzthQsXMnPmTDp06JDwtkWkaQrgNNelSxemTp3K4sWLE9ru4cOHefzxx5k1a1ZC2xWR5lMAZ4CCggLKy8s5evRowtosLS1l8uTJdO3aNWFtikh8FMAZoEePHowdO5YHHnggIe0dO3aMZcuWMXfu3IS0JyItowDOEIWFhZSWlvL++++fc1tLly5l9OjR5ObmnnthItJiCuAMMXDgQK666ipWrFhxTu1UVVVRWlpKUVFRgioTkZZSAGeQSCRCcXEx1dXVLW5j5cqVDBgwgEGDBiWwMhFpCQVwBhk+fDgXXXQRv/rVr1p0/JkzZyguLtaiOyJpQgGcQcyMSCRCNBpt0VKV69evp2PHjowYMSLxxYlI3BTAGWb
  892. "text/plain": [
  893. "<Figure size 432x288 with 1 Axes>"
  894. ]
  895. },
  896. "metadata": {
  897. "needs_background": "light"
  898. },
  899. "output_type": "display_data"
  900. }
  901. ],
  902. "source": [
  903. "ax = plt.gca()\n",
  904. "ax.set_title('Steps Distribution for July')\n",
  905. "ax.boxplot(steps_per_day['value'], vert=False,manage_ticks=False, notch=True)\n",
  906. "plt.xlabel(\"Steps Per Day\")\n",
  907. "ax.set_yticks([])\n",
  908. "plt.show()"
  909. ]
  910. },
  911. {
  912. "cell_type": "markdown",
  913. "metadata": {},
  914. "source": [
  915. "Wrapping that all into a single function we get something like this:"
  916. ]
  917. },
  918. {
  919. "cell_type": "code",
  920. "execution_count": 23,
  921. "metadata": {},
  922. "outputs": [],
  923. "source": [
  924. "def readFileIntoDataFrame(fName):\n",
  925. " steps_df = pd.read_json(fName, convert_dates=True)\n",
  926. "\n",
  927. " steps_df['date_minus_time'] = steps_df[\"dateTime\"].apply( lambda steps_df : \n",
  928. " datetime.datetime(year=steps_df.year, month=steps_df.month, day=steps_df.day))\t\n",
  929. "\n",
  930. " steps_df.set_index(steps_df[\"date_minus_time\"],inplace=True)\n",
  931. " return steps_df.resample('D').sum()\n",
  932. "\n",
  933. "def graphBoxAndWhiskers(data, title, xlab):\n",
  934. " ax = plt.gca()\n",
  935. " ax.set_title(title)\n",
  936. " ax.boxplot(data['value'], vert=False, manage_ticks=False, notch=True)\n",
  937. " plt.xlabel(xlab)\n",
  938. " ax.set_yticks([])\n",
  939. " plt.show()"
  940. ]
  941. },
  942. {
  943. "cell_type": "code",
  944. "execution_count": 24,
  945. "metadata": {},
  946. "outputs": [
  947. {
  948. "data": {
  949. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWsAAAEWCAYAAACg+rZnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAb60lEQVR4nO3deZRU9bnu8e97mRSIIiEqMrUgTjc3cT7xGhJRQQQErxMIrYA4oMk1MTjQNGg3WescBZlBEXEecA4ac3L0JEYTGUTmMTjco0cTkW4miXo8Au/9Y+/Som16rOpdv67nsxaL6l1Vez/dq/vpt37VtcvcHRERyW3/I+kAIiJSPZW1iEgAVNYiIgFQWYuIBEBlLSISAJW1iEgAVNYiIgFQWQsAZvZjM1tkZjvNbJuZLTSzU+PrhpvZGwlkqvNxzexMM/so05lEktI06QCSPDM7CHgJuA54GmgO9AC+TDJXY2RmTd19d9I5JDyarAXgaAB3n+/ue9z9C3d/xd3XmNlxwBzgdDP7h5ntADCzFmZ2l5n9p5l9YmZzzOzA+LozzewjMxtrZuVm9r6ZDU0dzMz6mtkGM9tlZn8zs5tqEjLez01mtiZ+BPCUmR1Qw/uOMLON8T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4L7697PHtYO4Lgb3ACnd/vxZZJE+Z3nxAMs3MzgQei9e/k8owgOgJwxo9AZkEM3sVeMLd5yWdRXKfXhQjjY6ZNSV6EnNZ0ln2J3516ElEf9YnUi0tg0ijYmYHA9uIntAsTThOpczsYaJlo1/GSzQi1dIyiIhIADRZi4gEoFZr1u3atfOCgoIsRRERaZyWL19e7u7fq/6W+1ersi4oKGDZspx9zkZEJCeZ2Qf13YeWQUREAqCyFhEJgMpaRCQAKmsRkQCorEVEAqCyFhEJgMpaRCQAOpGTZNSSJUv4/PPPk45Bq1atOO2004jegSxMu3fvZuHChezZ883pvtu3b89xxx2XYCpJispaMmbr1q306NGDHj16VH/jLNuwYQNz585lwIABSUepszvuuIOHHnqIzp07A/DZZ5+xa9cuNmzYkHAySYLKWjJm7969tGnThldfrc2blWfHggULKC0t5fzzzw9yut65cyfTp09n0aJFdO/eHYBNmzYF/ctH6kdr1tIoDRw4kL179/Lb3/426Sh1MmPGDPr27ft1UYuorKVRMjNuv/12SkpKCO00wDt27GDGjBmMGzcu6SiSQ1TW0mgNHDgQd+fFF2vzdovJmzFjBv369dNULftQWUujZWaUlJQENV3v2LGDmTNnaqqWb1FZS6M2YMAAzIwXXngh6Sg1Mn36dPr3789RRx2VdBTJMSpradTSp+u9e/cmHadKmqqlKiprafTOP/98mjRpkvPT9bRp0xgwYADdunVLOorkIJW1NHqp6bq0tDRnp+sdO3Ywa9YsiouLk44iOUplLXmhf//+NG3alAULFiQdpVJTp05l4MCBmqplv1TWkhdyebrevn07s2fP1lQtVVJZS97o168fzZs35ze/+U3SUfaRmqq7du2adBTJYSpryRu5OF1v27aNu+++W1O1VEtlLXmlb9++HHDAATz//PNJRwGiqfqCCy7QVC3VUllLXsml6VpTtdSGylryznnnnUfLli157rnnEs0xZcoULrzwQo488shEc0gYVNaSd3Jhut66dSv33HOPpmqpMZW15KU+ffrQqlWrxKbrqVOnctFFF1FQUJDI8SU8KmvJS0lO16mpeuzYsQ16XAmbylryVp8+fWjduj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OPvss3n00Uc1VUuD0GQtUks9evSga9eu9OrVixEjRmiqlgahshapg9LSUjZv3swtt9ySdBTJEw22DGJmuHtDHU4kq84
  950. "text/plain": [
  951. "<Figure size 432x288 with 1 Axes>"
  952. ]
  953. },
  954. "metadata": {
  955. "needs_background": "light"
  956. },
  957. "output_type": "display_data"
  958. }
  959. ],
  960. "source": [
  961. "graphBoxAndWhiskers(readFileIntoDataFrame(\"data/steps-2020-01-27.json\"), \"Steps In January\", \"Steps Per Day\")"
  962. ]
  963. },
  964. {
  965. "cell_type": "markdown",
  966. "metadata": {},
  967. "source": [
  968. "That is cool, but, what if we could view the distribution for each month in the same graph?\n",
  969. "Based on the two previous graphs, my step distribution during July looked distinctly different from my step distribution in January. \n",
  970. "The first difficultly would be to read in all the files since Fitbit creates a new file for every month.\n",
  971. "The next thing would be to group them by month and then graph it."
  972. ]
  973. },
  974. {
  975. "cell_type": "code",
  976. "execution_count": 25,
  977. "metadata": {},
  978. "outputs": [
  979. {
  980. "name": "stdout",
  981. "output_type": "stream",
  982. "text": [
  983. "['steps-2019-04-02.json', 'steps-2019-08-30.json', 'steps-2020-02-26.json', 'steps-2019-10-29.json', 'steps-2019-07-01.json', 'steps-2020-01-27.json', 'steps-2019-07-31.json', 'steps-2019-06-01.json', 'steps-2019-09-29.json', '.ipynb_checkpoints', 'steps-2019-12-28.json', 'steps-2019-05-02.json', 'calories', 'steps-2019-11-28.json', 'sleep']\n"
  984. ]
  985. }
  986. ],
  987. "source": [
  988. "import os\n",
  989. "files = os.listdir(\"data\")\n",
  990. "print(files)"
  991. ]
  992. },
  993. {
  994. "cell_type": "code",
  995. "execution_count": 26,
  996. "metadata": {},
  997. "outputs": [],
  998. "source": [
  999. "dfs = []\n",
  1000. "for file in files: # this can take 15 seconds\n",
  1001. " if \"steps\" in file: # finds the steps files\n",
  1002. " dfs.append(readFileIntoDataFrame(\"data/\" + file))"
  1003. ]
  1004. },
  1005. {
  1006. "cell_type": "code",
  1007. "execution_count": 27,
  1008. "metadata": {},
  1009. "outputs": [
  1010. {
  1011. "data": {
  1012. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAEWCAYAAABYGk2QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAaMUlEQVR4nO3de5jUV33H8feXZWERSMItMRDCQvZGJEITGkmDFWyizaXFS6KiVlG01VajrT6tLTYlz1NMjdb6xNRaI62xWhITL422aaKRmGJzg1xIKLss13ALsOEWKNBl+faP35nN7OzM7MzuzByY/byeZ56d+d3O+Z39zWfPnN9vf2PujoiIVN6Q2BUQERmsFMAiIpEogEVEIlEAi4hEogAWEYlEASwiEokCWGSQMrN6M3MzGxq7LoOVArgCzGyumf23mR0ys/1m9isz+/Uwb5GZrYpQp0Vm1mVmR8zssJk9a2bXl3D7bmZHw/ZfNrOHzezdpdp+RlnzzGxHibf5iJl9pI9lvmlmbWZ2yswWZcybYWYPmlmHmfV5sX1orz3pYWhmQ81sbyHrF8LMtprZVaXYlpSGArjMzOws4KfA14CxwCTgFuBEzHoFj7n7KOAcYDnwfTMbW8wG+ug9zQzbbwa+DdxhZn/V38qehp4D/hB4Osu8TuD7wOIitncQuCbt9bXAgX7XTk5/7q5HGR/AbOBgjnnTgeNAF3AktRwwHPgy8CKwB/gGMCLMmwfsAP4C6AC2Au9L2+a1wP8ArwA7gc/mKHsRsCrt9UjAgdnh9fXAsySh8N/A69OW3Qr8GbCW5A/J0Czbd6AhY9oNYX/HhdcfAtaHum4G/iBt2ReA30l7XRv2d1aWsuYBO3Ls53XAM8BhYDuwNG1eHfBd4OWwn08B5wHLwu/kePi93NHH73gVsCjHvIbkbdbnceLA54F706bdByxJXx+YCNwP7Ac2Ah9Nm7eUJPS/E9p0Xdrv81+AU8CxsE9/CtSHcj8YjrUOYEna9i4HVoe22wN8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lRtuuKEMNctt3bp1vOtd7+p7QZHTlMaABYDm5mba2tr6tW5bWxvNzc0lrpFI9VMACwAtLS20trYWvV5nZydbtmyhsbGxDLUSqW4KYAH6H8CbN29m0qRJ1NXVlaFWItVNASxAMgSxYcMGTp06VdR6ra2tugpBpJ8UwALA6NGjGTNmDNu3by9qPQWwSP8pgKVbf4Yh2traFMAi/aQAlm79uRKitbVVV0CI9JMCWLoV2wN2dw1BiAyAAli6FRvA+/btA2DChF5fdSUiBVAAS7diAzjV++3P/SNERAEsaSZNmsThw4c5dOhQQctr+EFkYBTA0m3IkCE0NTUVfCJOV0CIDIwCWHpoaWkpOIDVAxYZGAWw9FDMOLAuQRMZGAWw9FBoAB8/fpydO3cybdq0CtRKpDopgKWHQgO4vb2dqVOnUltbW4FaiVQnBbD00NjYyObNmzl58mTe5XQCTmTgFMDSw4gRI3jta1/b53fa6QScyMApgKWXQq6EUACLDJwCWHopZBxYV0CIDJwCWHrpK4DdXd8DJ1ICCmDppa8A3rVrFyNHjmTMmDEVrJVI9VEASy/Nzc15A1jjvyKloQCWXs477zxOnjxJR0dH1vkKYJHSUABLL2aW90oIBbBIaSiAJat848C6AkKkNBTAklVfAawesMjAKYAlq1wBfOTIEV5++WUuvPDCCLUSqS4KYMkq15UQGzZsoLGxkZqamgi1EqkuCmDJ6qKLLmL79u2cOHGix3QNP4iUjgJYsho2bBhTpkxh06ZNPaYrgEVKRwEsOWUbB9YVECKlowCWnLIFsO4DLFI6CmDJKfNEXFdXF+3t7TQ1NUWslUj1UABLTpk94BdffJHx48czatSoiLU
  1013. "text/plain": [
  1014. "<Figure size 432x288 with 1 Axes>"
  1015. ]
  1016. },
  1017. "metadata": {
  1018. "needs_background": "light"
  1019. },
  1020. "output_type": "display_data"
  1021. }
  1022. ],
  1023. "source": [
  1024. "stepsPerDay = pd.concat(dfs)\n",
  1025. "graphBoxAndWhiskers(stepsPerDay, \"Steps Per Day Last 11 Months\", \"Steps per Day\")"
  1026. ]
  1027. },
  1028. {
  1029. "cell_type": "code",
  1030. "execution_count": 28,
  1031. "metadata": {},
  1032. "outputs": [
  1033. {
  1034. "name": "stdout",
  1035. "output_type": "stream",
  1036. "text": [
  1037. "<class 'numpy.ndarray'>\n",
  1038. "DatetimeIndex(['2019-04-03', '2019-04-04', '2019-04-05', '2019-04-06',\n",
  1039. " '2019-04-07', '2019-04-08', '2019-04-09', '2019-04-10',\n",
  1040. " '2019-04-11', '2019-04-12',\n",
  1041. " ...\n",
  1042. " '2019-12-19', '2019-12-20', '2019-12-21', '2019-12-22',\n",
  1043. " '2019-12-23', '2019-12-24', '2019-12-25', '2019-12-26',\n",
  1044. " '2019-12-27', '2019-12-28'],\n",
  1045. " dtype='datetime64[ns]', name='date_minus_time', length=342, freq=None)\n",
  1046. " value month week_day\n",
  1047. "date_minus_time \n",
  1048. "2019-04-03 510 4 2\n",
  1049. "2019-04-04 11453 4 3\n",
  1050. "2019-04-05 12684 4 4\n",
  1051. "2019-04-06 12910 4 5\n",
  1052. "2019-04-07 3368 4 6\n",
  1053. "... ... ... ...\n",
  1054. "2019-12-24 5779 12 1\n",
  1055. "2019-12-25 4264 12 2\n",
  1056. "2019-12-26 4843 12 3\n",
  1057. "2019-12-27 9609 12 4\n",
  1058. "2019-12-28 2218 12 5\n",
  1059. "\n",
  1060. "[342 rows x 3 columns]\n"
  1061. ]
  1062. }
  1063. ],
  1064. "source": [
  1065. "print(type(stepsPerDay['value'].to_numpy()))\n",
  1066. "print(stepsPerDay['value'].keys())\n",
  1067. "\n",
  1068. "stepsPerDay['month'] = pd.DatetimeIndex(stepsPerDay['value'].keys()).month \n",
  1069. "stepsPerDay['week_day'] = pd.DatetimeIndex(stepsPerDay['value'].keys()).weekday\n",
  1070. "\n",
  1071. "print(stepsPerDay)"
  1072. ]
  1073. },
  1074. {
  1075. "cell_type": "markdown",
  1076. "metadata": {},
  1077. "source": [
  1078. "## Graphing Steps by Month\n",
  1079. "\n",
  1080. "Now that we have columns for the total amount of steps per day and the months, we can plot all the data on a single plot using the group by operator in the plotting library."
  1081. ]
  1082. },
  1083. {
  1084. "cell_type": "code",
  1085. "execution_count": 29,
  1086. "metadata": {},
  1087. "outputs": [
  1088. {
  1089. "data": {
  1090. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZwAAAEcCAYAAADz8QLhAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOzdeXxU9bn48c+ThC1hCQQIO2EnLArigooaCta1VbtKW7Ut1d7eVrv9bqult3tu9d7e9rbetrdLFLU11ta61B0xQcEF2bcQCJCwJGSBkIWQbfL8/pgzdgizz2Qmy/N+veaVmXO+Z77fM0nOM+e7iqpijDHGdLWkRBfAGGNM32ABxxhjTFxYwDHGGBMXFnCMMcbEhQUcY4wxcWEBxxhjTFxYwDG9loisFpGfJLociRbocxCRz4rI+niXKdZ6y3n0dhZwTJcTkVIROSMijSJSKyIviMjERJfLm4ioiExPdDlMcCKS5fy+UhJdFhMeCzgmXj6kqoOBsUAl8GCCy9NlxM3+t4zpxP4pTFypajPwN2COZ5uIDBORR0WkWkTKROS7ngu2iPxWRP7mlfYBEVnrXNRzROSoiHxHRGqcO6lP+8tbRO4UkRIROSkiz4nIOGf7G06S7c5d2Cd9HJssIv/t5HNIRL7i/S1bRApFJFdENgBNwFQRGefkc9LJ906v9zurmstzLl6vS0XkPhHZ49wVPiwiA7323ygi20TklIi8JSLnee1bKCJbRKRBRP4CvH+c/49GHhSROhHZKyLLnI0fF5HNnRJ+U0Se8fMmhSLyE6c8jSLyDxHJEJE/i0i9iLwnIlle6S9zttU5Py/r9F4/FpENznm8KiIjnd2e39cpJ59LvY77mfN5HRKR64Kct4k3VbWHPbr0AZQCy53nqcAjwKNe+x8FngWGAFnAPmClV/p9wGeBK4AaYIKzLwdoB34ODACuAk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LqxbtDHGmLiwOxxjjDFxYQHHGGNMXFjAMcYYExcWcIwxxsSFBRxjjDFx0edmGhg5cqRmZWVFfPzp06dJS0sLnrALJDLvROffV/NOdP527nbukdi8eXONqo46Z0eilxyN92PRokUajYKCgqiO76l5Jzr/vpp3ovO3c0+cnnzuwCa1JaaNMcYkigUcY4wxcWEBxxhjTFxYwDHGGBMXFnCMMcbEhQUcY7qp/Px85s2bx7Jly5g3bx75+ba0jenZ+tw4HGN6gvz8fFatWkVeXh4ul4vk5GRWrlwJwIoVKxJcOmMiY3c4xnRDubm55OXlsXTpUlJSUli6dCl5eXnk5uYmumjGRMwCjjHdUFFREUuWLDlr25IlSygqKkpQiYyJngUcY7qh7Oxs1q9ff9a29evXk52dnaASGRM9CzjGdEOrVq1i5cqVFBQU0N7eTkFBAStXrmTVqlWJLpoxEbNOA8Z0Q56OAXfffTdFRUVkZ2eTm5trHQZMj2YBx5huasWKFaxYsYLCwkJycnISXRxjomZVasYYY+LCAo4xxpi4sIBjjDEmLizgGGOMiQsLOMYYY+LCeqmZbklEgqZxr2RrjOkp7A7HdEud10Kf/O3nz9lmjOlZLOAYY4yJCws4xhhj4sICjjHGmLiwgGOMMSYuLOAYY4yJCws4xhjTjeTn5zNv3jyWLVvGvHnzyM/PT3SRYsbG4RhjTDeRn5/PqlWryMvLw+VykZyczMqVKwF6xdIUdodjjDHdRG5uLnl5eSxdupSUlBSWLl1KXl4eubm5iS5aTFjAMcaYbqKoqIglS5actW3JkiUUFRUlqESxZQHHGGO6iezsbNavX3/WtvXr15OdnZ2gEsVWlwUcEZkoIgUiUiQiu0Xkq872ESKyRkT2Oz+Hex1zn4iUiEixiFzjtX2RiOx09v1KnIm2RGSAiPzF2f6uiGR11fkYY0xXW7VqFStXrqS
  1091. "text/plain": [
  1092. "<Figure size 432x288 with 1 Axes>"
  1093. ]
  1094. },
  1095. "metadata": {
  1096. "needs_background": "light"
  1097. },
  1098. "output_type": "display_data"
  1099. }
  1100. ],
  1101. "source": [
  1102. "ax = plt.gca()\n",
  1103. "ax.set_title('Steps Distribution for July\\n')\n",
  1104. "stepsPerDay.boxplot(column=['value'], by='month',ax=ax, notch=True)\n",
  1105. "plt.xlabel(\"Month\")\n",
  1106. "plt.ylabel(\"Steps Per Day\")\n",
  1107. "plt.show()"
  1108. ]
  1109. },
  1110. {
  1111. "cell_type": "code",
  1112. "execution_count": 30,
  1113. "metadata": {},
  1114. "outputs": [
  1115. {
  1116. "data": {
  1117. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZwAAAEcCAYAAADz8QLhAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3dd3hUVfrA8e9LAoTeCSVA6FWRYkcMUsWCbRXUVXdZ2+r+1FVXFMu6LrZV1N1VV1bsirpiR5pIUJAOUkMg9FCkl9DS3t8f92Z3iMlkZjJzJ5m8n+eZh5k795z7nhly37nnnnuuqCrGGGNMpFWKdgDGGGMqBks4xhhjPGEJxxhjjCcs4RhjjPGEJRxjjDGesIRjjDHGE5ZwTLkjIm+JyF+jHUe0+fscROQmEZntdUyhEJFkEVERiS9lPZtEZEC44jLhZwnHhMz9Az8mIlkisl9EJolIi2jH5cvdkbWLdhzGGEs4pvQuUdWaQFPgZ+AfUY4nYsRhfzPGhMj+eExYqOpx4BOgS8EyEakjIu+IyG4R2SwiDxfssEXkVRH5xGfdZ0RkhrtTTxGRTBF5SET2uEdS1xW3bRG5WUQyRGSfiHwpIs3c5d+7qyxzj8KuKaJsnIg8725no4jc6du9IyKpIjJGROYAR4E2ItLM3c4+d7s3+9R3UjdXQVt8Xm8SkQdFZLV7VPimiCT4vH+xiPwkIgdE5EcROdXnvR4iskREDovIR8B/yxX/0cg/ROSgiKwRkf7uwl+JyOJCK94rIp8XUUE/EVnh8/pbEVng83q2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YYMGjDEmxhUMDPjDH/5
  1118. "text/plain": [
  1119. "<Figure size 432x288 with 1 Axes>"
  1120. ]
  1121. },
  1122. "metadata": {
  1123. "needs_background": "light"
  1124. },
  1125. "output_type": "display_data"
  1126. }
  1127. ],
  1128. "source": [
  1129. "ax = plt.gca()\n",
  1130. "ax.set_title('Steps Distribution By Week Day\\n')\n",
  1131. "stepsPerDay.boxplot(column=['value'], by='week_day',ax=ax, notch=True)\n",
  1132. "plt.xlabel(\"Week Day\")\n",
  1133. "plt.ylabel(\"Steps Per Day\")\n",
  1134. "plt.show()"
  1135. ]
  1136. },
  1137. {
  1138. "cell_type": "markdown",
  1139. "metadata": {},
  1140. "source": [
  1141. "## Future Work\n",
  1142. "\n",
  1143. "Moving forward with this I would like to do more visualizations with sleep data and heart rate."
  1144. ]
  1145. }
  1146. ],
  1147. "metadata": {
  1148. "kernelspec": {
  1149. "display_name": "Python 3",
  1150. "language": "python",
  1151. "name": "python3"
  1152. },
  1153. "language_info": {
  1154. "codemirror_mode": {
  1155. "name": "ipython",
  1156. "version": 3
  1157. },
  1158. "file_extension": ".py",
  1159. "mimetype": "text/x-python",
  1160. "name": "python",
  1161. "nbconvert_exporter": "python",
  1162. "pygments_lexer": "ipython3",
  1163. "version": "3.7.6"
  1164. }
  1165. },
  1166. "nbformat": 4,
  1167. "nbformat_minor": 4
  1168. }