This Python notebook parses the database exported by the sleep tracking mobile app Pillow into Pandas DataFrames for easy manipulation. It can then then produce the summary data and render the plots found in the app.
The advantage of using this code is that it includes the audio events in the graph of the sleep stages as purple vertical lines as seen in the Example Output section below.
Pillow exports UTC timestampes. I hardcoded in my own timezone with pytz.timezone('US/Eastern')
, so you will want to adjust it to your own timezone.
Exporting the output, for example, to share with your doctor, is a bit of a pain. I had the best luck exporting the notebook to markdown and then editing the markdown output to remove everything I didn't want in the document. Then I exported the markdown to universally readable html. This is way more complicated than it needs to be, so consider it an invitation to improve upon my code.
<style type="text/css"> *{stroke-linecap:butt;stroke-linejoin:round;} </style>Time in bed | 6:49:34 | Sleep quality | 58% |
Time asleep | 6:34:34 | Mood | 🙁 Not so good |
Time to sleep | 0:15:00 | Notes |
Awake | 17%⬤ | REM | 9%⬤ |
Light Sleep | 23%⬤ | Deep Sleep | 51%⬤ |
Author(s): Robert Jacobson
License: © 2018 Robert Jacobson. I intend to share these works with the most permissive license possible. In regions where there is the legal concept of public domain, I release these works into the public domain. In regions that do not have a legal concept of public domain, I release these works under the MIT License. See LICENSE.txt for details.