Learn practical skills, build real-world projects, and advance your career

My Youtube History Analysis

Cover

In this project, we are going to analyse our personal Youtube history using Pandas with Python. First, we will get our Youtube history from Google Takeout. Then we will create the dataset of this information using JSON, HTML parser and Pandas. Then, We will analyse the dataset using Python analysis techniques and libraries (Pandas, Matplotlib, Seaborn, etc. ) learned in Data Analysis with Python: Zero to Pandas course. I highly recommend this course if you're a beginner in this field.

How to run the code

This is an executable Jupyter notebook hosted on Jovian.ml, a platform for sharing data science projects. You can run and experiment with the code in a couple of ways: using free online resources (recommended) or on your own computer.

Option 1: Running using free online resources (1-click, recommended)

The easiest way to start executing this notebook is to click the "Run" button at the top of this page, and select "Run on Binder". This will run the notebook on mybinder.org, a free online service for running Jupyter notebooks. You can also select "Run on Colab" or "Run on Kaggle".

Option 2: Running on your computer locally
  1. Install Conda by following these instructions. Add Conda binaries to your system PATH, so you can use the conda command on your terminal.

  2. Create a Conda environment and install the required libraries by running these commands on the terminal:

conda create -n zerotopandas -y python=3.8 
conda activate zerotopandas
pip install jovian jupyter numpy pandas matplotlib seaborn opendatasets --upgrade
  1. Press the "Clone" button above to copy the command for downloading the notebook, and run it on the terminal. This will create a new directory and download the notebook. The command will look something like this:
jovian clone notebook-owner/notebook-id
  1. Enter the newly created directory using cd directory-name and start the Jupyter notebook.
jupyter notebook

You can now access Jupyter's web interface by clicking the link that shows up on the terminal or by visiting http://localhost:8888 on your browser. Click on the notebook file (it has a .ipynb extension) to open it.

Downloading the Dataset

First, we will have to download our Youtube history from Google Takeout. Google gives data in different formats for eg. Youtube history in HTML format, Subscription list in JSON etc.

That means we will have to use different Python modules to create final Pandas DataFrame that we can use to do our detailed analysis.

pip install lxml
Collecting lxml Downloading lxml-4.6.3-cp38-cp38-manylinux1_x86_64.whl (5.4 MB) |████████████████████████████████| 5.4 MB 4.1 MB/s eta 0:00:01 Installing collected packages: lxml Successfully installed lxml-4.6.3 Note: you may need to restart the kernel to use updated packages.
pip install pafy
Collecting pafy Downloading pafy-0.5.5-py2.py3-none-any.whl (35 kB) Installing collected packages: pafy Successfully installed pafy-0.5.5 Note: you may need to restart the kernel to use updated packages.