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

WhatsApp Group Chat Analysis w/ Python

In this notebook, we'll see how you can analyze whatsapp group chat data using python

Useful links

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", but you'll need to create an account on Google Colab or Kaggle to use these platforms.

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 whatsapp-chat-analysis -y python=3.8 
conda activate whatsapp-chat-analysis
pip install jovian jupyter numpy pandas matplotlib seaborn wordcloud emoji --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.

How to obtain Whatsapp Chat data

  • Step 1: Open whatsapp
  • Step 2: Open a Group/Inbox
  • Step 3: Click on the 3 dotted options button
  • Step 4: Click on more
  • Step 5: Click on export chat
  • Step 6: Click on without media
  • Step 7: Export via Email/other IM's/....
  • Step 8: Download to your system rename to chat-data.txt and put it in a folder

Data Preparation and Cleaning

# Importing the libraries 

import re
import pandas as pd
import numpy as np

import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

from wordcloud import WordCloud, STOPWORDS
import emoji
from collections import Counter

import os
import jovian
[jovian] Update Available: 0.2.18 --> 0.2.20 [jovian] Run `!pip install jovian --upgrade` to upgrade