Screen Time Analysis using Python

Screen Time Analysis lets you know how much time you spend on what kind of applications and websites using your device. And screen time analysis gives a visual report of the same. So, if you want to learn how to analyze screen time, this article is for you. In this article, I will take you through the task of Screen Time Analysis using Python.

Screen Time Analysis

Screen Time Analysis is the task of analyzing and creating a report on which applications and websites are used by the user for how much time. Apple devices have one of the best ways of creating a screen time report.

Screen Time Analysis on iPhone

For the task of screen time analysis, I found an ideal dataset that contains data about:

  1. Date 
  2. Usage of Applications 
  3. Number of Notifications from Applications 
  4. Number of times apps opened

You can download the dataset from here.

In the section below, I will take you through the task of Screen Time Analysis using Python.

Screen Time Analysis using Python

Let’s start the task of screen time analysis by importing the necessary Python libraries and the dataset:

import pandas as pd
import numpy as np
import plotly.express as px
import plotly.graph_objects as go

data = pd.read_csv("Screentime - App Details.csv")
print(data.head())
         Date  Usage  Notifications  Times opened        App
0  08/26/2022     38             70            49  Instagram
1  08/27/2022     39             43            48  Instagram
2  08/28/2022     64            231            55  Instagram
3  08/29/2022     14             35            23  Instagram
4  08/30/2022      3             19             5  Instagram

Now let’s have a look if the dataset has any null values or not:

data.isnull().sum()
Date             0
Usage            0
Notifications    0
Times opened     0
App              0
dtype: int64

The dataset doesn’t have any null values. Now let’s have a look at the descriptive statistics of the data:

print(data.describe())
            Usage  Notifications  Times opened
count   54.000000      54.000000     54.000000
mean    65.037037     117.703704     61.481481
std     58.317272      97.017530     43.836635
min      1.000000       8.000000      2.000000
25%     17.500000      25.750000     23.500000
50%     58.500000      99.000000     62.500000
75%     90.500000     188.250000     90.000000
max    244.000000     405.000000    192.000000

Now let’s start with analyzing the screen time of the user. I will first look at the amount of usage of the apps:

figure = px.bar(data_frame=data, 
                x = "Date", 
                y = "Usage", 
                color="App", 
                title="Usage")
figure.show()
Screen Time Analysis: Usage

Now let’s have a look at the number of notifications from the apps:

figure = px.bar(data_frame=data, 
                x = "Date", 
                y = "Notifications", 
                color="App", 
                title="Notifications")
figure.show()
Notifications

Now let’s have a look at the number of times the apps opened:

figure = px.bar(data_frame=data, 
                x = "Date", 
                y = "Times opened", 
                color="App",
                title="Times Opened")
figure.show()
Screen Time Analysis: Times Opened

We generally use our smartphones when we get notified by any app. So let’s have a look at the relationship between the number of notifications and the amount of usage:

figure = px.scatter(data_frame = data, 
                    x="Notifications",
                    y="Usage", 
                    size="Notifications", 
                    trendline="ols", 
                    title = "Relationship Between Number of Notifications and Usage")
figure.show()
Relationship Between Number of Notifications and Usage of smartphones

There’s a linear relationship between the number of notifications and the amount of usage. It means that more notifications result in more use of smartphones.

Summary

So this is how we can analyze the screen time of a user using the Python programming language. Screen Time Analysis is the task of analyzing and creating a report on which applications and websites are used by the user for how much time. I hope you liked this article on Screen Time Analysis using Python. Feel free to ask valuable questions in the comments section below.

Aman Kharwal
Aman Kharwal

I'm a writer and data scientist on a mission to educate others about the incredible power of data📈.

Articles: 1498

Leave a Reply