def calls_by_csr(): call_file = p.parse(CALL_DATA, ",") begin_date = "August 1, 2014" end_date = "August 31, 2014" counter = Counter( item["Agent"] for item in call_file if item["Date/Time"] >= begin_date and item["Date/Time"] <= end_date and item["Call Status"] == "Completed" and item["Minutes"] > "1") call_list = [ counter["Brent Gauthier"], counter["Joey Doughty"], counter["Matt Intemann"], counter["Branton Phillips"], counter["Matt Averyhart"], counter["Jacob Ellis"], counter["Charles Marczynski"] ] csr_list = tuple( ["BJ", "Joey", "Iceman", "Branton", "Averyhart", "Jacob", "Chuck"]) xlocations = na.array(range(len(csr_list))) + 0.5 width = 0.5 rects1 = plt.bar(xlocations, call_list, width, color='green') plt.xticks(xlocations + width / 2, csr_list, rotation=90) plt.subplots_adjust(bottom=0.2) plt.rcParams['figure.figsize'] = 12, 12 plt.suptitle("Inbound & Outboud Calls Per Rep From " + begin_date + " to " + end_date, fontsize=12) plt.ylabel("Number of Inbound & Outbound Calls > 1 min", fontsize=12) autolabel(rects1) plt.savefig("phone_calls_graph.png") plt.clf()
def visualize_days(): """Visualize data by day of week""" #grab our parsed data tha we parsed earlier data_file = prs.parse(MY_FILE, ",") #make a new variable, 'counter', from iterating through each #line of data in the parsed data, and count how many incidents #happen on each day of the week counter = Counter(item["DayOfWeek"] for item in data_file) #for item in data_file: #separate the x-axis data (the days of the week) from the #return counter #'counter' variable from the y-axis data (the number of #incidents for each day) data_list = [ counter["Monday"], counter["Tuesday"], counter["Wednesday"], counter["Thursday"], counter["Friday"], counter["Saturday"], counter["Sunday"] ] day_tuple = tuple(["Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"]) # with that y-axis data, assign it tho a matplotlib plot instance plt.plot(data_list) #create the amount of ticks needed for our x-axis, and assign #the labels plt.xticks(range(len(day_tuple)), day_tuple) #save the plot plt.savefig("Days.png") #close plot file plt.clf()
def booked_moves_by_csr(): order_file = p.parse(BELLHOP_ORDER, ",") begin_date = raw_input("Start date: ") end_date = raw_input("End date: ") counter = Counter( item["booked_by"] for item in order_file if item["booked_at_date"] >= begin_date and item["booked_at_date"] <= end_date and item["deposit_paid"] != "") booked_list = [ counter["*****@*****.**"], counter["*****@*****.**"] ] csr_list = tuple(["Averyhart", "Graves"]) xlocations = na.array(range(len(csr_list))) + 0.5 width = 0.5 rects1 = plt.bar(xlocations, booked_list, width, color='green') plt.xticks(xlocations + width / 2, csr_list, rotation=90) plt.subplots_adjust(bottom=0.2) plt.rcParams['figure.figsize'] = 12, 12 plt.suptitle("Booked Moves from " + begin_date + " to " + end_date, fontsize=12) plt.ylabel("Moves Booked", fontsize=12) autolabel(rects1) plt.savefig("manager_booked_moves_bar_graph.png") plt.clf()
def create_contested_order_list(): contest_file = p.parse(TICKET_FILE, ",") contested_orders = [] for ticket in contest_file: split_sub = ticket["Subject"].split() if range(len(split_sub)) > range( 0, 3) and ticket["Created at"] > "2014-10-01 08:00": if split_sub[0] == 'Contested:': contested_orders.append(split_sub[1]) elif split_sub[3] == 'contesting': contested_orders.append(split_sub[7]) return contested_orders
def moves_per_hour_worked_by_csr(): order_file = p.parse(BELLHOP_ORDER, ",") begin_date = raw_input("Start date: ") end_date = raw_input("End date: ") ice_hours = raw_input("Ice Hours: ") joey_hours = raw_input("Joey Hours: ") bj_hours = raw_input("BJ Hours: ") chuck_hours = raw_input("Chuck Hours: ") jacob_hours = raw_input("Jacob Hours: ") justin_hours = raw_input("Justin Hours: ") tisha_hours = raw_input("Tisha Hours: ") olivia_hours = raw_input("Olivia Hours: ") aaron_hours = raw_input("Aaron Hours: ") stacy_hours = raw_input("Stacy Hours: ") counter = Counter( item["booked_by"] for item in order_file if item["booked_at_date"] >= begin_date and item["booked_at_date"] <= end_date and item["deposit_paid"] != "") booked_list = [ (float(counter["*****@*****.**"]) / float(ice_hours)), (float(counter["*****@*****.**"]) / float(joey_hours)), (float(counter["*****@*****.**"]) / float(bj_hours)), (float(counter["*****@*****.**"]) / float(chuck_hours)), (float(counter["*****@*****.**"]) / float(jacob_hours)), (float(counter["*****@*****.**"]) / float(justin_hours)), (float(counter["*****@*****.**"]) / float(tisha_hours)), (float(counter["*****@*****.**"]) / float(olivia_hours)), (float(counter["*****@*****.**"]) / float(aaron_hours)), (float(counter["*****@*****.**"]) / float(stacy_hours)) ] csr_list = tuple([ "Iceman", "Joey", "BJ", "Chuck", "Jacob", "Justin", "Tisha", "Olivia", "Aaron", "Stacy" ]) xlocations = na.array(range(len(csr_list))) + 0.5 width = 0.5 rects1 = plt.bar(xlocations, booked_list, width, color='green') plt.xticks(xlocations + width / 2, csr_list, rotation=90) plt.subplots_adjust(bottom=0.2) plt.rcParams['figure.figsize'] = 12, 12 plt.suptitle("Booked moves per hour worked from " + begin_date + " to " + end_date, fontsize=12) plt.ylabel("Booked Moves Per Hour Worked", fontsize=12) autolabel(rects1) plt.savefig("moves_per_hour_worked_by_csr.png") plt.clf()
def visualize_type(): """Visualize data by category in a bar graph""" data_file = prs.parse(MY_FILE, ",") counter = Counter(item["Category"] for item in data_file) labels = tuple(counter.keys()) xlocations = na.array(range(len(day))) + 0.5 width = 0.5 plt.bar(xlocations, counter.values(), width=width) plt.xticks(xlocations + width / 2, labels, rotation=90) plt.subplots_adjust(bottom=0.4) plt.rcParams['figure.figsize'] = 12, 8 plt.savefig("Type.png") plt.clf()
def frequent_customer(): order_file = p.parse(BELLHOP_ORDER, ",") customer_em = [] ems = set() for item in order_file: if (item['charges_verified'] == "Yes" and item['deposit_paid'] != ''): customer_em.append(item['customer_email']) for email in customer_em: if (customer_em.count(email) > 2 and item['customer_email'] == email and item['move_date'] > "2014-11-10" and item['customer_review_score'] > 4.8): ems.add(email) e = list(ems) for i in e: print i
def truck_moves(): order_file = p.parse(BELLHOP_ORDER, ",") begin_date = raw_input("Start date: ") end_date = raw_input("End date: ") counter = Counter( item["truck_required"] for item in order_file if item["booked_at_date"] >= begin_date and item["booked_at_date"] <= end_date and item["cancelled"] != "Yes") counter2 = Counter(item["charges_verified"] for item in order_file if item["booked_at_date"] >= begin_date and item["booked_at_date"] <= end_date) truck_list = counter["Yes"] verified_moves = counter2["Yes"] print truck_list print verified_moves
def calls_by_csr(): call_file = p.parse(CALL_DATA, ",") begin_date = raw_input("Start date (Month dd, yyyy): ") end_date = raw_input("End date( Month dd, yyyy): ") ice_hours = raw_input("Ice Hours: ") joey_hours = raw_input("Joey Hours: ") branton_hours = raw_input("Branton Hours: ") bj_hours = raw_input("BJ Hours: ") chuck_hours = raw_input("Chuck Hours: ") averyhart_hours = raw_input("Averyhart Hours: ") jacob_hours = raw_input("Jacob Hours: ") counter = Counter( item["Agent"] for item in call_file if item["Date/Time"] >= begin_date and item["Date/Time"] <= end_date and item["Call Status"] == "Completed" and item["Minutes"] > "1") call_list = [(float(counter["Brent Gauthier"]) / float(bj_hours)), (float(counter["Joey Doughty"]) / float(joey_hours)), (float(counter["Matt Intemann"]) / float(ice_hours)), (float(counter["Branton Phillips"]) / float(branton_hours)), (float(counter["Matt Averyhart"]) / float(averyhart_hours)), (float(counter["Jacob Ellis"]) / float(jacob_hours)), (float(counter["Charles Marczynski"]) / float(chuck_hours))] csr_list = tuple( ["BJ", "Joey", "Iceman", "Branton", "Averyhart", "Jacob", "Chuck"]) xlocations = na.array(range(len(csr_list))) + 0.5 width = 0.5 rects1 = plt.bar(xlocations, call_list, width, color='green') plt.xticks(xlocations + width / 2, csr_list, rotation=90) plt.subplots_adjust(bottom=0.2) plt.rcParams['figure.figsize'] = 12, 12 plt.suptitle("Inbound & Outboud Calls Per Hour Worked From " + begin_date + " to " + end_date, fontsize=12) plt.ylabel("Inbound & Outboud Calls Per Hour Worked > 1 min", fontsize=12) autolabel(rects1) plt.savefig("phone_calls_per_hour_graph.png") plt.clf()
def booked_moves_by_csr(): order_file = p.parse(BELLHOP_ORDER, ",") print order_file begin_date = raw_input("Start date: ") end_date = raw_input("End date: ") counter = Counter( item["booked_by"] for item in order_file if item["booked_at_date"] >= begin_date and item["booked_at_date"] <= end_date and item["deposit_paid"] != "") booked_list = [ counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"], counter["*****@*****.**"] ] csr_list = tuple([ "Iceman", "Joey", "BJ", "Chuck", "Jacob", "Justin", "Tisha", "Olivia", "Aaron", "Stacy" ]) xlocations = na.array(range(len(csr_list))) + 0.5 width = 0.5 rects1 = plt.bar(xlocations, booked_list, width, color='green') plt.xticks(xlocations + width / 2, csr_list, rotation=90) plt.subplots_adjust(bottom=0.2) plt.rcParams['figure.figsize'] = 12, 12 plt.suptitle("Booked Moves from " + begin_date + " to " + end_date, fontsize=12) plt.ylabel("Moves Booked", fontsize=12) autolabel(rects1) plt.savefig("booked_moves_bar_graph.png") plt.clf()
def total_inbound_calls(): inbounds = [] completed = [] abandoned_queue = [] left_voicemail = [] abandoned_unknown = [] abandoned_voicemail = [] call_file = p.parse(CALL_DATA, ",") begin_date = "August 1, 2014" end_date = "August 31, 2014" for item in call_file: if item['Wait Time'] != '': inbounds.append(float(item['Wait Time'])) if item['Call Status'] == "Completed" and item[ 'Agent'] == "Voicemail": left_voicemail.append(float(item['Wait Time'])) elif item['Call Status'] == "Abandoned In Queue": abandoned_queue.append(float(item['Wait Time'])) elif item['Call Status'] == "Completed" and item[ 'Agent'] != "Voicemail": completed.append(float(item['Wait Time'])) elif item['Call Status'] == "Abandoned Unknown" or item[ 'Call Status'] == "Abandoned": abandoned_unknown.append(float(item['Wait Time'])) elif item['Call Status'] == "Abandoned In Voicemail": abandoned_voicemail.append(float(item['Wait Time'])) total_inbound = float(len(inbounds)) aw_in = float(na.average(inbounds)) voicemails = float(len(left_voicemail)) per_vm = (voicemails / total_inbound) * 100 aw_vm = float(na.average(left_voicemail)) hangup_voicemail = float(len(abandoned_voicemail)) per_hvm = (hangup_voicemail / total_inbound) * 100 aw_hvm = float(na.average(abandoned_voicemail)) complete_calls = float(len(completed)) per_cc = (complete_calls / total_inbound) * 100 aw_cc = float(na.average(completed)) hangup_queue = float(len(abandoned_queue)) per_hq = (hangup_queue / total_inbound) * 100 aw_hq = float(na.average(abandoned_queue)) aban_un = float(len(abandoned_unknown)) aw_un = float(na.average(abandoned_unknown)) per_un = (aban_un / total_inbound) * 100 print "---------" * 8 print "Inbound Call Data from %s to %s" % (begin_date, end_date) print "---------" * 8 print "Total Inbound Calls: %.2f" % total_inbound print "Avg Wait For All Inbound: %.2f seconds" % aw_in print "---------" * 8 print "\tCalls Completed (%.2f%% of Total Inbound): %.2f" % ( per_cc, complete_calls) print "\t\tAvg. Wait: %.2f seconds" % aw_cc print "\tVoicemails Left (%.2f%% of Total Inbound): %.2f" % (per_vm, voicemails) print "\t\tAvg. Wait: %.2f seconds" % aw_vm print "\tHung up in Voicemail (%.2f%% of Total Inbound): %.2f" % ( per_hvm, hangup_voicemail) print "\t\tAvg. Wait: %.2f seconds" % aw_hvm print "\tHung up in Queue (%.2f%% of Total Inbound): %.2f" % (per_hq, hangup_queue) print "\t\tAvg. Wait: %.2f seconds" % aw_hq print "\tAbandoned Unknown (%.2f%% of Total Inbound): %.2f" % (per_un, aban_un) print "\t\tAvg. Wait: %.2f seconds" % aw_un
from collections import Counter import csv import numpy as np import p1_parse as p from bookedmoves import BELLHOP_ORDER #first tip 2014-03-08 #2014-05-01 when refund data occured order_file = p.parse(BELLHOP_ORDER, ",") begin_date = '2014-09-01' #raw_input("Start date: ") end_date = '2014-10-01' #raw_input("End date: ") vm_counter = Counter( item['charges_verified'] == "Yes" for item in order_file if item['move_date'] >= begin_date and item['move_date'] <= end_date and item['deposit_paid'] != '') verified_moves = float(vm_counter[True]) print verified_moves def bellhops_assigned(): hops = [] for item in order_file: if (item['charges_verified'] == "Yes" and item['move_date'] >= begin_date and item['move_date'] <= end_date and item['deposit_paid'] != '' and item['bellhops_assigned'] != "0"): hops.append(float(item['bellhops_assigned'])) avg_hops_per_job = np.average(hops) print "Average Bellhops Per Move: %.2f" % avg_hops_per_job
from collections import Counter from operator import truediv import datetime import csv import re import p1_parse as p from bookedmoves import BELLHOP_ORDER TICKET_FILE = "../data/report-feed-export-2014-12-01-1626-429105ca2f-v2.csv" order_file = p.parse(BELLHOP_ORDER, ",") ticket_file = p.parse(TICKET_FILE, ",") begin_date = raw_input("Start date (yyyy-mm-dd): ") end_date = raw_input("End date (yyyy-mm-dd): ") def job_fills_per_tyson(agent): jobs_filled = [] markets_filled = [] agent_hours = float(raw_input("%s's hours: " % agent)) for item in ticket_file: solved_date = item['Solved at'] agent_solved = item['Assignee'] sub = item["Subject"] split_sub = re.split("\W+", sub) if range(len(split_sub)) > range(0): if (split_sub[0].lower() == 'fill' and solved_date >= begin_date and solved_date <= end_date and agent == agent_solved): jobs_filled.append(float(item['Summation column'])) if (split_sub[2] == 'San' or split_sub[2] == 'College' or split_sub[2] == 'Baton' or split_sub[2] == 'Boca'
from collections import Counter import re import matplotlib.pyplot as plt import numpy as na import p1_parse as p BELLHOP_ORDER = "../data/chart-300192.csv" TICKETS_FILE = "../data/report-feed-export-2015-02-02-1331-429105ba40-v2.csv" ZOPIMS_FILE = "../data/report592867-5j0ccic3ESQvL6Vl.csv" PHONE_FILE = "../data/agent_availability.csv" order_file = p.parse(BELLHOP_ORDER, ",") ticket_file = p.parse(TICKETS_FILE, ",") zopim_file = p.parse(ZOPIMS_FILE, ",") phone_call_file = p.parse(PHONE_FILE, ",") begin_date = raw_input("Start date (yyyy-mm-dd): ") end_date = raw_input("End date (yyyy-mm-dd): ") agts = [] point = [] def point_function(agent): agent_hours = float(raw_input("%s's hours: " % agent)) thank_you_vids = [] tix_sovled = [] jobs_filled = [] moves = [] touches = []
from collections import Counter import datetime import csv import p1_parse as p from bookedmoves import BELLHOP_ORDER order_database = p.parse(BELLHOP_ORDER, ",") def pay_structure(): for item in order_database: booked_datetime = (datetime.datetime.strptime(item['booked_at_date'] +' '+item['booked_at_time'], '%Y-%m-%d %I:%M:%S %p %Z')) move_datetime = (datetime.datetime.strptime(item['move_date'] +' '+item['move_time'], '%Y-%m-%d %I:%M:%S %p %Z')) captain_claim_datetime = (datetime.datetime.strptime(item['captain_claim_time'] +' '+item['captain_claim_time'], '%Y-%m-%d %I:%M:%S %p %Z') wingman_claim_datetime = (datetime.datetime.strptime(item['wingman_claim_time'] +' '+item['captain_claim_time'], '%Y-%m-%d %I:%M:%S %p %Z') if booked_datetime - move_datetime <= datetime.timedelta(hours=12): #Captain and Wingman for same day jobs captain_pay = 18.0 wingman_pay = 16.0 return (captain_pay, wingman_pay) if (booked_datetime - move_datetime <= datetime.timedelta(days=7) and booked_datetime - move_datetime > datetime.timedelta(hours=12)): pay_decrease_interval = (booked_datetime - move_datetime)/6
from collections import Counter from operator import truediv import datetime import csv import p1_parse as p from bookedmoves import BELLHOP_ORDER BELLHOP_PROFILES = "../data/2014_10_31_1752_bellhops_export.csv" order_file = p.parse(BELLHOP_ORDER, ",") bellhops_file = p.parse(BELLHOP_PROFILES, ',') begin_date = "2014-05-01" end_date = "2014-10-31" def movers_in_cities(market_input): unique_hops = set() for item in order_file: markets = item['market'] + ',' + ' ' + item['state'] if (item['charges_verified'] == "Yes" and item['move_date'] >= "2014-02-01" and item['move_date'] <= "2014-10-15" and item['deposit_paid'] != '' and markets == market_input and item['bellhops_assigned'] != '' and item['bellhops_assigned'] > '0'): unique_hops.add(item['captain']) wing_list = item['wingmen'].split() for i in wing_list: unique_hops.add(i) total = len(unique_hops) return total
def market_performance(): order_file = p.parse(BELLHOP_ORDER, ",") market =
from collections import Counter import csv import matplotlib.pyplot as plt import numpy.numarray as na import p1_parse as p CHAMBLISS_FILE = "../data/DMP20-Table 1.csv" chambliss = p.parse(CHAMBLISS_FILE, ",") def vol_report(): bus = [] num_vol_hours_bus = [] num_vols_bus = [] chruch = [] foundation = [] individual = [] organization = [] school = [] for item in chambliss: if item['ContactType'] == "Business": if item['Company'] not in bus: bus.append(item['Company']) for item in bus: num_vols_bus.append(sum(int(item['Number of volunteers involved']))) print bus print num_vols_bus #bus_sort = sorted(bus)
def main(): data = p.parse(p.MY_FILE, ",") return create_map(data)