[6674fe]: / analytics / Analysis_Björn.ipynb

Download this file

93 lines (92 with data), 2.4 kB

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Glucose Analysis "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Sleep Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load dataset\n",
    "df = pd.read_csv('../data/garmin/sleep.csv', sep=',')\n",
    "\n",
    "# Drop not needed columns\n",
    "df = df.drop(columns=['User Id', 'User Last Name', 'User Email', 'Team Names', 'Group Names', \n",
    "                      'Calendar Date (UTC)', 'Start Time (UTC)', 'End Time (UTC)',\n",
    "                     'Source', 'Validation', 'Time Zone (s)', 'Timezone (Local)', 'Summary Id'])\n",
    "\n",
    "# Convert data types\n",
    "df['Calendar Date (Local)'] = pd.to_datetime(df['Calendar Date (Local)'])\n",
    "df['Start Time (Local)'] = pd.to_datetime(df['Start Time (Local)'])\n",
    "df['End Time (Local)'] = pd.to_datetime(df['End Time (Local)'])\n",
    "df['Processing Time'] = pd.to_datetime(df['Processing Time'])\n",
    "df['SleepPhaseStartTime'] = pd.to_datetime(df['SleepPhaseStartTime'])\n",
    "#df['SleepPhaseEndTime'] = df['SleepPhaseEndTime'].str.replace('T',' ')\n",
    "df['SleepPhaseEndTime'] = pd.to_datetime(df['SleepPhaseEndTime'], format='mixed')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Select user = P14 and day = 2023-12-24\n",
    "df_p12 = df[df['User First Name'] == 'P12']\n",
    "df_p12_xmas = df_p12[df_p12['Calendar Date (Local)'] == '2023-12-24']\n",
    "\n",
    "# Print\n",
    "df_p12_xmas"
   ]
  }
 ],
 "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.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}