Skip to content
0

SleepInc: Helping you find better sleep 😴

📖 Background

Your client is SleepInc, a sleep health company that recently launched a sleep-tracking app called SleepScope. The app monitors sleep patterns and collects users' self-reported data on lifestyle habits. SleepInc wants to identify lifestyle, health, and demographic factors that strongly correlate with poor sleep quality. They need your help to produce visualizations and a summary of findings for their next board meeting! They need these to be easily digestible for a non-technical audience!

💾 The data

SleepInc has provided you with an anonymized dataset of sleep and lifestyle metrics for 374 individuals. This dataset contains average values for each person calculated over the past six months.

The dataset includes 13 columns covering sleep duration, quality, disorders, exercise, stress, diet, demographics, and other factors related to sleep health.

ColumnDescription
Person IDAn identifier for each individual.
GenderThe gender of the person (Male/Female).
AgeThe age of the person in years.
OccupationThe occupation or profession of the person.
Sleep Duration (hours)The average number of hours the person sleeps per day.
Quality of Sleep (scale: 1-10)A subjective rating of the quality of sleep, ranging from 1 to 10.
Physical Activity Level (minutes/day)The average number of minutes the person engages in physical activity daily.
Stress Level (scale: 1-10)A subjective rating of the stress level experienced by the person, ranging from 1 to 10.
BMI CategoryThe BMI category of the person (e.g., Underweight, Normal, Overweight).
Blood Pressure (systolic/diastolic)The average blood pressure measurement of the person, indicated as systolic pressure over diastolic pressure.
Heart Rate (bpm)The average resting heart rate of the person in beats per minute.
Daily StepsThe average number of steps the person takes per day.
Sleep DisorderThe presence or absence of a sleep disorder in the person (None, Insomnia, Sleep Apnea).

Acknowledgments: Laksika Tharmalingam, Kaggle: https://www.kaggle.com/datasets/uom190346a/sleep-health-and-lifestyle-dataset (this is a fictitious dataset)

import pandas as pd
df = pd.read_csv('sleep_health_data.csv')
df

2 hidden cells
def check_df(dataframe, head):
    print("##################### Shape/Satır ve Sütun #####################")
    print(dataframe.shape)
    print("##################### Types/Veri Tipleri #####################")
    print(dataframe.dtypes)
    print("##################### Info/Sütunların genel bilgileri #####################")
    print(dataframe.info())
    print("##################### Tail/Son n satır #####################")
    print(dataframe.tail(head))
    print("##################### NA/BoÅŸ veri #####################")
    print(dataframe.isnull().sum())
    print("##################### Quantiles/Sayısal Kritikler #####################")
    print(dataframe.describe([0, 0.05, 0.50, 0.95, 0.99, 1]).T)

2 hidden cells
import numpy as np
import pandas as pd
check_df(df,3)
#Exploration or Manipulation for Sleep Diorder Column
df["Sleep Disorder"].value_counts()
df["Sleep Disorder"]=df["Sleep Disorder"].fillna("None")
df["Sleep Disorder"].value_counts()
#Basic statistical values for string columns
df.describe(include='O')
#last check nan columns before EDA
df.info()
#unique values number of columns
col_unique=df.nunique()
                        
print(col_unique)

Data Exploration

‌
‌
‌