Quick statistical summary¶
With the pandas groupby() and describe() methods one can generate a statistical summary for several populations in a dataset with very little effort.
In [1]:
import pandas as pd
# Import data
df = pd.read_csv('Smartphone_Usage_Productivity_Dataset_50000.csv')
# Check what columns we have to work with
print(df.columns)
Group data by Gender and Occupation and apply .describe() to the Daily_Phone_Hours column.
We can keep it tidy by rounding the numbers.
In [2]:
# Group data and apply .describe()
df = df.groupby(['Gender', 'Occupation'])['Daily_Phone_Hours'].describe()
# Round numbers
df = df.round(2)
print(df)
This tutorial uses the "Screen Time, Sleep & Stress Analysis Dataset" available on Kaggle under the CC0: Public Domain license.
source: https://www.kaggle.com/datasets/amar5693/screen-time-sleep-and-stress-analysis-dataset