Skip to content

Instantly share code, notes, and snippets.

@py-ranoid
Last active January 18, 2022 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save py-ranoid/b98644815f0330b69242c809e0eda3ec to your computer and use it in GitHub Desktop.
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
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