top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Building a Health Data Dashboard Using Plotly in Python

Updated: Sep 4

Introduction

In today’s world, wearable devices and continuous glucose monitors are producing more data than ever before. But raw numbers alone don’t tell us much — the real challenge is to transform messy lifestyle data into actionable insights.

In my recent study, as a journey of data analytics, learned how to handle even the collaborative use of GitHub. Though that too plays an important role of building my dashboard in Python. Which i will be sharing that part too in this health data in between. So that, some might may find it useful during their journey of learnings....

Here's a Diabetes Dataset is taken. This is a real-world dataset from 25 individuals with Type 1 Diabetes, tracking their health using Fitbit Ionic smartwatches over a minimum of 14 days.

The dataset is unique because it combines multiple data streams, giving us a complete picture of each patient's life:

           Medical Data: Continuous Glucose Monitoring (CGM) and insulin doses.

           Lifestyle Data: Daily steps, calories, heart rate, and both the quantity and quality of sleep.

The primary objective is to move beyond simple tracking to find actionable insights. Aim to understand the complex relationships between daily habits and glucose control to provide data-driven recommendations for better health.


Data Validation: validated the dataset against the study's 14-day participation requirement. A key finding from data validation is the varied participation length. While four patients met the minimum 14-day requirement, three of these participants provided a much richer dataset, with data spanning from 89 days up to 573 days.


Key Areas of Investigation: identifying optimal sleep patterns, quantifying the benefit of exercise, and building models to predict future glucose levels, combining steps, sleep, carb intake, and glucose levels. Building an interactive dashboard that could uncover patterns between daily habits and glucose stability. Here’s the analysis made along the way.


1. The Data Journey: Cleaning First, Insights Later

Like most real-world health data, dataset wasn’t perfect, encountered:

  • Missing values: Sleep logs and step counts weren’t always recorded.

  • Inconsistent formats: Columns like "Sleep Quality (1-10)" vs "sleep_quality" required normalization.

  • Outliers: 30,000 steps in a day? Possible, but rare — these values needed special treatment.

The first lesson: 80% of the time in data science goes into cleaning and preparation. Once we standardized column names and handled NaNs, the path to analysis became clearer.


2. Visualizing Lifestyle Patterns

Built a dashboard using Plotly, Matplotlib, and Seaborn, focusing on intuitive visualizations.

  • Steps Distribution: Histograms showed that most patients averaged 4,000–8,000 steps per day, with only a few outliers hitting marathon-like numbers.

    ree
  • Sleep Duration & Quality: Boxplots revealed sleep variability across patients. Interestingly, poor sleep quality often coincided with shorter durations.

    Sleep Duration Distribution
    Sleep Duration Distribution
    Sleep Quality Distribution
    Sleep Quality Distribution
  • Carbs vs Glucose: A scatterplot with a trendline highlighted the direct relationship between carb intake and post-meal glucose spikes. Adding color by sleep quality showed that better-rested patients often had smoother glucose responses.

    Carb Intake VS Glucose Levels
    Carb Intake VS Glucose Levels
  • Correlation Heatmap: Glucose had stronger links with carb intake and sleep duration than steps, hinting that meal timing and rest may outweigh physical activity in short-term glucose control.

    Correlation Heatmap
    Correlation Heatmap
  • Decision trees: flagged late meals + inactivity as high-risk combinations.

ree

  • Predictive Modeling: Regression models and pairplots revealed hidden patterns—like how step count and carb intake jointly affect glucose variability, also flagged outliers using thresholding and variability indices.


3. Technical Hurdles to Overcome

Building the dashboard wasn’t just drag-and-drop. Some challenges included:

  • Synchronizing time-stamped glucose readings with daily lifestyle logs.

  • Choosing derived features like “glucose variability” or “sleep efficiency” without making the model too complex.

  • Managing skewed data distributions, where a simple average didn’t tell the full story.

  • Keeping the dashboard clean and readable with appropriate color scales and labels.


4. Collaboration with GitHub

Another major takeaway was Using GitHub:

  • Learned to manage branches, commits, and pull requests.

  • Organized the repo into /data, /notebooks, /figures for clarity.

  • Fixing errors like “Invalid JSON in notebook” taught us the importance of versioning Jupyter notebooks carefully.

More than just code, good collaboration practice  is needed.


5. Key Insights on Lifestyle & Glucose

The most exciting part was the findings:

  • Sleep matters: Longer, better-quality sleep was linked to steadier glucose.

  • Carbs drive spikes: As expected, higher carb intake correlated strongly with glucose peaks.

  • Steps had an indirect effect: While not strongly correlated daily, physical activity may still support long-term glucose stability.

  • Consistency wins: Patients with regular routines (consistent sleep + meal times) had better overall control.


Conclusion

Python can turn messy health data into powerful dashboards for both patients and clinicians. Beyond the technical skills, the experience highlighted how sleep, diet, and activity intertwine with glucose regulation — and how collaborative coding practices make it possible.

Lifestyle data isn’t just noise—it’s a signal waiting to be decoded. We can move from reactive care to predictive insight. Whether you're an analyst, a clinician, or a curious patient, the tools are here.

As healthcare continues moving toward data-driven insights, dashboards like these can bridge the gap between raw data and real-world decisions.

The question is: are we ready to listen to what the data is telling us?


Happy Learnings!!


 
 

+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page