Last active
January 18, 2022 09:35
-
-
Save py-ranoid/b98644815f0330b69242c809e0eda3ec to your computer and use it in GitHub Desktop.
Visualising number of texts initiated by participants of a WhatsApp thread over time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
with open('/Users/vishalgupta/Downloads/WhatsApp Chat with MopHead.txt','r') as f: | |
backup_text = f.read() | |
matches = re.findall('\n([0-9]+[/][0-9]+[/][0-9]+, [0-9]+[:][0-9]+ [AP]M - [a-zA-Z ]+[:])',backup_text) | |
sender_df = pd.DataFrame([{'time':pd.to_datetime(row.split('-')[0].strip()),'sender':row.split('-')[1].strip().replace(':','')} for row in matches]) | |
sender_df.groupby('sender').time.hist(bins=30) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment