Skip to content

Instantly share code, notes, and snippets.

@hirokai
Created January 3, 2015 08:05
Show Gist options
  • Save hirokai/9ec36b2be10c43a4868a to your computer and use it in GitHub Desktop.
Save hirokai/9ec36b2be10c43a4868a to your computer and use it in GitHub Desktop.
Email reply time histogram
import matplotlib.pyplot as plt
import csv
import numpy as np
ns = []
ms = []
with open('result.csv','rb') as f:
reader = csv.reader(f)
for row in reader:
if not row[3].startswith('Fwd'):
ns.append(float(row[0])/(60*60)) # time in hours
ms.append([float(row[0])/(60*60)] + row[1:])
print "%d emails" % (len(ns))
# print filter(lambda m: m[0] > 24 * 7, ms)
# print max(ms,key=lambda a: a[0])
plt.hist(ns,bins=range(0,24*60,1),normed=True)
plt.xlim([0,24*7])
plt.xticks(np.arange(0, 24*7, 24))
plt.xlabel('Time to reply [hr]')
plt.ylabel('Normalized frequency')
plt.show()
plt.hist(ns,bins=range(0,24*60,1),cumulative=True, normed=True)
plt.xlim([0,24*7])
plt.xticks(np.arange(0, 24*7, 24))
plt.ylim([0,1])
plt.xlabel('Time to reply [hr]')
plt.ylabel('Normalized cumulative frequency')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment