The code you have provided appears to be calculating a variety of metrics related to customer service agents, such as attendance rate, schedule adherence, and skillset proficiency. These metrics can be useful for understanding the performance of individual agents or for comparing the performance of different agents or teams. Some of the metrics you are calculating, such as average handle time and average wait time, can also be useful for understanding the customer experience and for identifying areas for improvement.
ID agent | abandonment rate | agent absenteeism rate | agent attendance rate | attendance by time | availability rate | certification rate | productivity by time | satisfaction score | schedule adherence | schedule adherence by time | schedule efficiency | schedule efficiency by time | schedule flexibility | schedule flexibility by time | skillset diversity | skillset effectiveness | skillset proficiency | skillset utilization | training completion rate | turnover rate | turnover rate by reason | turnover rate by time | utilization rate | average acw time by reason | average acw time by time | average wait time | average wait time by time | average handle time | average handle time by reason | average handle time by time | average hold time | average hold time by reason | average hold time by time | average queue time by reason | average queue time by time | average speed to answer | average speed to answer by time | average talk time | average talk time by reason | average talk time by time | average time in acw | average time in acw by reason | average time in acw by time | average time in queue | average time in queue before abandoning | average time in queue before abandoning by reason | average time in queue before abandoning by |
---|
import pandas as pd
import numpy as np
python: data = pd.read_csv("data.csv")
python: abandonment_rate = data[data["status"] == "abandoned"].count() / data["status"].count()
python: agent_absenteeism_rate = data[data["absent"] == 1].count() / data["absent"].count()
python: agent_attendance_rate = data[data["attended"] == 1].count() / data["attended"].count()
python: attendance_by_time = data.groupby("time_of_day")["attended"].mean()
python: availability_rate = data[data["available"] == 1].count() / data["available"].count()
python: certification_rate = data[data["certified"] == 1].count() / data["certified"].count()
python: productivity_by_time = data.groupby("time_of_day")["productivity"].mean()
python: satisfaction_score = data["satisfaction"].mean()
python: schedule_adherence = data[data["adhered_to_schedule"] == 1].count() / data["adhered_to_schedule"].count()
python: schedule_adherence_by_time = data.groupby("time_of_day")["adhered_to_schedule"].mean()
python: schedule_efficiency = data["scheduled_time"].sum() / data["actual_time"].sum()
python: schedule_efficiency_by_time = data.groupby("time_of_day")["scheduled_time"].sum() / data.groupby("time_of_day")["actual_time"].sum()
python: schedule_flexibility = data[data["schedule_changes"] > 0].count() / data["schedule_changes"].count()
python: schedule_flexibility_by_time = data.groupby("time_of_day")["schedule_changes"].mean()
python: skillset_diversity = data["skillset"].nunique() / data["skillset"].count()
python: skillset_effectiveness = data[data["effective_use_of_skillset"] == 1].count() / data["effective_use_of_skillset"].count()
python: skillset_proficiency = data["skillset_proficiency"].mean()
python: skillset_utilization = data[data["utilized_skillset"] == 1].count() / data["utilized_skillset"].count()
python: training_completion_rate = data[data["training_completed"] == 1].count() / data["training_completed"].count()
python: turnover_rate = data[data["left_company"] == 1].count() / data["left_company"].count()
python: turnover_rate_by_reason = data.groupby("reason_for_leaving")["left_company"].mean()
python: turnover_rate_by_time = data.groupby("time_of_day")["left_company"].mean()
python: utilization_rate = data[data["utilized"] == 1].count() / data["utilized"].count()
python: average_acw_time_by_reason = data.groupby("call_reason")["after_call_work_time"].mean()
python: average_acw_time_by_time = data.groupby("time_of_day")["after_call_work_time"].mean()
python: average_wait_time = data["wait_time"].mean()
python: average_wait_time_by_time = data.groupby("time_of_day")["wait_time"].mean()
python: average_handle_time = data["handle_time"].mean()
python: average_handle_time_by_reason = data.groupby("call_reason")["handle_time"].mean()
python: average_handle_time_by_time = data.groupby("time_of_day")["handle_time"].mean()
python: average_hold_time = data["hold_time"].mean()
python: average_hold_time_by_reason = data.groupby("call_reason")["hold_time"].mean()
python: average_hold_time_by_time = data.groupby("time_of_day")["hold_time"].mean()
python: average_queue_time_by_reason = data.groupby("call_reason")["queue_time"].mean()
python: average_speed_to_answer = data["speed_to_answer"].mean()
python: average_speed_to_answer_by_time = data.groupby("time_of_day")["speed_to_answer"].mean()
python: average_talk_time = data["talk_time"].mean()
python: average_talk_time_by_reason = data.groupby("call_reason")["talk_time"].mean()
python: average_talk_time_by_time = data.groupby("time_of_day")["talk_time"].mean()
python: average_time_in_acw = data["after_call_work_time"].mean()
python: average_time_in_acw_by_reason = data.groupby("call_reason")["after_call_work_time"].mean()
python: average_time_in_acw_by_time = data.groupby("time_of_day")["after_call_work_time"].mean()
python: average_time_in_queue = data["queue_time"].mean()
python: average_time_in_queue_before_abandoning = data[data["status"] == "abandoned"]["queue_time"].mean()
python: average_time_in_queue_before_abandoning_by_reason = data[data["status"] == "abandoned"].groupby("call_reason")["queue_time"].mean()
python: average_time_in_queue_before_abandoning_by_time = data[data["status"] == "abandoned"].groupby("time_of_day")["queue_time"].mean()
python: average_time_in_queue_before_disconnecting = data[data["status"] == "disconnected"]["queue_time"].mean()
python: average_time_in_queue_before_disconnecting_by_reason = data[data["status"] == "disconnected"].groupby("call_reason")["queue_time"].mean()
python: average_time_in_queue_before_disconnecting_by_time = data[data["status"] == "disconnected"].groupby("time_of_day")["queue_time"].mean()
python: average_time_in_queue_before_transferring = data[data["status"] == "transferred"]["queue_time"].mean()
python: average_time_in_queue_before_transferring_by_reason = data[data["status"] == "transferred"].groupby("call_reason")["queue_time"].mean()
python: average_time_in_queue_before_transferring_by_time = data[data["status"] == "transferred"].groupby("time_of_day")["queue_time"].mean()
python: average_wrap_up_time = data["wrap_up_time"].mean()
python: average_wrap_up_time_by_reason = data.groupby("call_reason")["wrap_up_time"].mean()
python: average_wrap_up_time_by_time = data.groupby("time_of_day")["wrap_up_time"].mean()
python: call_abandonment_rate_by_reason = data[data["status"] == "abandoned"].groupby("call_reason").count() / data.groupby("call_reason").count()
python: call_abandonment_rate_by_time = data[data["status"] == "abandoned"].groupby("time_of_day").count() / data.groupby("time_of_day").count()
python: call_back_rate = data[data["call_back_requested"] == 1].count() / data["call_back_requested"].count()
python: call_back_rate_by_time = data[data["call_back_requested"] == 1].groupby("time_of_day").count() / data.groupby("time_of_day").count()
python: customer_effort_score = data["customer_effort"].mean()
python: customer_satisfaction_by_reason = data.groupby("call_reason")["customer_satisfaction"].mean()
python: customer_satisfaction_score = data["customer_satisfaction"].mean()
python: first_call_resolution_rate = data[data["first_call_resolution"] == 1].count() / data["first_call_resolution"].count()
python: first_call_resolution_rate_by_reason = data[data["first_call_resolution"] == 1].groupby("call_reason").count() / data.groupby("call_reason").count()
python: net_promoter_score = data["net_promoter_score"].mean()
python: net_promoter_score_by_reason = data.groupby("call_reason")["net_promoter_score"].mean()
python: net_promoter_score_by_time = data.groupby("time_of_day")["net_promoter_score"].mean()
python: quality_assurance_score = data["quality_assurance_score"].mean()
python: service_level = data[data["call_answer_time"] <= data["service_level_goal"]].count() / data["call_answer_time"].count()
python: service_level_by_reason = data[data["call_answer_time"] <= data["service_level_goal"]].groupby("call_reason").count() / data.groupby("call_reason").count()
python: service_level_by_time = data[data["call_answer_time"] <= data["service_level_goal"]].groupby("time_of_day").count() / data.groupby("time_of_day").count()
python: training_budget = data["training_cost"].sum()
python: training_churn_rate = data[data["left_company_after_training"] == 1].count() / data["left_company_after_training"].count()
python: training_cost_per_agent = data["training_cost"].sum() / data["agent_id"].nunique()
python: training_cost_per_day = data["training_cost"].sum() / data["training_days"].sum()
python: training_cost_per_hour = data["training_cost"].sum() / (data["training_days"].sum() * 8)
python: training_cost_per_month = data["training_cost"].sum() / (data["training_days"].sum() / 30)
python: training_cost_per_week = data["training_cost"].sum() / (data["training_days"].sum() / 7)
python: training_cost_per_year = data["training_cost"].sum() / (data["training_days"].sum() / 365)
python: training_effectiveness = data[data["training_effective"] == 1].count() / data["training_effective"].count()
python: training_efficiency = data["training_days"].sum() / data["agent_id"].nunique()
python: training_completed = data[data["training_completed"] == 1].count()
python: training_churn = data[(data["training_completed"] == 1) & (data["left_company"] == 1)].count()
python: training_retention_rate = 1 - (training_churn / training_completed)
python: call_resolution_rate = data[data["status"] == "resolved"].count() / data["status"].count()
python: call_resolution_rate_by_time = data[data["status"] == "resolved"].groupby("time_of_day").count() / data.groupby("time_of_day").count()
python: call_routing_efficiency = data[data["call_routed_correctly"] == 1].count() / data["call_routed_correctly"].count()
python: call_routing_efficiency_by_time = data[data["call_routed_correctly"] == 1].groupby("time_of_day").count() / data.groupby("time_of_day").count()
python: call_transfer_rate = data[data["status"] == "transferred"].count() / data["status"].count()
python: call_transfer_rate_by_time = data[data["status"] == "transferred"].groupby("time_of_day").count() / data.groupby("time_of_day").count()
python: revenue_retention_rate = data[data["revenue_retained"] == 1].count() / data["revenue_retained"].count()
python: revenue_retention_rate_by_reason = data[data["revenue_retained"] == 1].groupby("call_reason").count() / data.groupby("call_reason").count()
python: revenue_retention_rate_by_time = data[data["revenue_retained"] == 1].groupby("time_of_day").count() / data.groupby("time_of_day").count()
python: capacity_utilization_rate = data["call_count"].sum() / (data["agent_id"].nunique() * data["hours_of_operation"].max())
python: cost_per_agent = data["agent_cost"].sum() / data["agent_id"].nunique()
python: cost_per_call = data["call_cost"].sum() / data["call_count"].sum()
python: cost_per_agent_by_reason = data.groupby("call_reason")["agent_cost"].sum() / data.groupby("call_reason")["agent_id"].nunique()
python: cost_per_agent_by_time = data.groupby("time_of_day")["agent_cost"].sum() / data.groupby("time_of_day")["agent_id"].nunique()
python: cost_per_call = data["call_cost"].sum() / data["call_count"].sum()
python: cost_per_call_by_reason = data.groupby("call_reason")["call_cost"].sum() / data.groupby("call_reason")["call_count"].sum()
python: cost_per_call_by_time = data.groupby("time_of_day")["call_cost"].sum() / data.groupby("time_of_day")["call_count"].sum()
python: cost_per_contact = data["contact_cost"].sum() / data["contact_count"].sum()
python: cost_per_contact_by_reason = data.groupby("call_reason")["contact_cost"].sum() / data.groupby("call_reason")["contact_count"].sum()
python: cost_per_contact_by_time = data.groupby("time_of_day")["contact_cost"].sum() / data.groupby("time_of_day")["contact_count"].sum()
python: cost_per_customer = data["customer_cost"].sum() / data["customer_count"].sum()
python: revenue_per_week = data["revenue"].sum() / (data["week"].nunique())
python: revenue_per_week_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["week"].nunique()
python: revenue_per_week_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["week"].nunique()
python: revenue_per_year = data["revenue"].sum() / (data["year"].nunique())
python: revenue_per_year_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["year"].nunique()
python: revenue_per_year_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["year"].nunique()
python: revenue_per_minute = data["revenue"].sum() / (data["call_duration"].sum() / 60)
python: revenue_per_minute_by_reason = data.groupby("call_reason")["revenue"].sum() / (data.groupby("call_reason")["call_duration"].sum() / 60)
python: revenue_per_minute_by_time = data.groupby("time_of_day")["revenue"].sum() / (data.groupby("time_of_day")["call_duration"].sum() / 60)
python: revenue_per_month = data["revenue"].sum() / (data["month"].nunique())
python: revenue_per_month_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["month"].nunique()
python: revenue_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["duration"].count()
python: revenue_per_hour = data["revenue"].sum() / (data["hours_of_operation"].max())
python: revenue_per_hour_by_reason = data.groupby("call_reason")["revenue"].sum() / (data.groupby("call_reason")["hours_of_operation"].max())
python: revenue_per_hour_by_time = data.groupby("time_of_day")["revenue"].sum() / (data.groupby("time_of_day")["hours_of_operation"].max())
python: revenue_per_interaction = data["revenue"].sum() / data["interaction_count"].sum()
python: revenue_per_interaction_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["interaction_count"].sum()
python: revenue_per_interaction_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["interaction_count"].sum()
python: revenue_per_customer = data["revenue"].sum() / data["customer_count"].sum()
python: revenue_per_customer_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["customer_count"].sum()
python: revenue_per_customer_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["customer_count"].sum()
python: revenue_per_day = data["revenue"].sum() / data["day"].nunique()
python: revenue_per_day_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["day"].nunique()
python: revenue_per_call = data["revenue"].sum() / data["call_count"].sum()
python: revenue_per_call_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["call_count"].sum()
python: revenue_per_call_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["call_count"].sum()
python: revenue_per_contact = data["revenue"].sum() / data["contact_count"].sum()
python: revenue_per_contact_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["contact_count"].sum()
python: revenue_per_contact_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["contact_count"].sum()
python: cost_per_customer_by_reason = data.groupby("call_reason")["cost"].sum() / data.groupby("call_reason")["customer_count"].sum()
python: cost_per_customer_by_time = data.groupby("time_of_day")["cost"].sum() / data.groupby("time_of_day")["customer_count"].sum()
python: cost_per_day = data["cost"].sum() / data["day"].nunique()
python: cost_per_day_by_reason = data.groupby("call_reason")["cost"].sum() / data.groupby("call_reason")["day"].nunique()
python: cost_per_day_by_time = data.groupby("time_of_day")["cost"].sum() / data.groupby("time_of_day")["day"].nunique()
python: cost_per_minute = data["cost"].sum() / (data["call_duration"].sum() / 60)
python: cost_per_minute_by_reason = data.groupby("call_reason")["cost"].sum() / (data.groupby("call_reason")["call_duration"].sum() / 60)
python: cost_per_minute_by_time = data.groupby("time_of_day")["cost"].sum() / (data.groupby("time_of_day")["call_duration"].sum() / 60)
python: cost_per_month = data["cost"].sum() / data["month"].nunique()
python: cost_per_month_by_reason = data.groupby("call_reason")["cost"].sum() / data.groupby("call_reason")["month"].nunique()
python: cost_per_month_by_time = data.groupby("time_of_day")["cost"].sum() / data.groupby("time_of_day")["month"].nunique()
python: cost_savings = data["initial_cost"].sum() - data["cost"].sum()
python: cost_savings_by_reason = data.groupby("call_reason")["initial_cost"].sum() - data.groupby("call_reason")["cost"].sum()
python: cost_savings_by_time = data.groupby("time_of_day")["initial_cost"].sum() - data.groupby("time_of_day")["cost"].sum()
python: efficiency_rate = (data["call_count"].sum() / data["hours_of_operation"].max()) / data["agent_count"].max()
python: efficiency_rate_by_reason = (data.groupby("call_reason")["call_count"].sum() / data.groupby("call_reason")["hours_of_operation"].max()) / data.groupby("call_reason")["agent_count"].max()
python: efficiency_rate_by_time = (data.groupby("time_of_day")["call_count"].sum() / data.groupby("time_of_day")["hours_of_operation"].max()) / data.groupby("time_of_day")["agent_count"].max()
python: occupancy_rate = (data["hours_of_operation"].max() - data["idle_time"].sum()) / data["hours_of_operation"].max()
python: performance_index = (data["call_count"].sum() / data["hours_of_operation"].max()) * data["satisfaction_score"].mean()
python: performance_index_by_reason = (data.groupby("call_reason")["call_count"].sum() / data.groupby("call_reason")["hours_of_operation"].max()) * data.groupby("call_reason")["satisfaction_score"].mean()
python: performance_index_by_time = (data.groupby("time_of_day")["call_count"].sum() / data.groupby("time_of_day")["hours_of_operation"].max()) * data.groupby("time_of_day")["satisfaction_score"].mean()
python: productivity_rate = data["call_count"].sum() / (data["hours_of_operation"].max() * data["agent_count"].max())
python: productivity_rate_by_reason = data.groupby("call_reason")["call_count"].sum() / (data.groupby("call_reason")["hours_of_operation"].max() * data.groupby("call_reason")["agent_count"].max())
python: productivity_rate_by_time = data.groupby("time_of_day")["call_count"].sum() / (data.groupby("time_of_day")["hours_of_operation"].max() * data.groupby("time_of_day")["agent_count"].max())
python: revenue_churn_rate = (data["initial_revenue"].sum() - data["revenue"].sum()) / data["initial_revenue"].sum()
python: revenue_churn_rate_by_reason = (data.groupby("call_reason")["initial_revenue"].sum() - data.groupby("call_reason")["revenue"].sum()) / data.groupby("call_reason")["initial_revenue"].sum()
python: revenue_churn_rate_by_time = (data.groupby("time_of_day")["initial_revenue"].sum() - data.groupby("time_of_day")["revenue"].sum()) / data.groupby("time_of_day")["initial_revenue"].sum()
python: revenue_growth = (data["revenue"].sum() - data["initial_revenue"].sum()) / data["initial_revenue"].sum()
python: revenue_growth_by_reason = (data.groupby("call_reason")["revenue"].sum() - data.groupby("call_reason")["initial_revenue"].sum()) / data.groupby("call_reason")["initial_revenue"].sum()
python: revenue_growth_by_time = (data.groupby("time_of_day")["revenue"].sum() - data.groupby("time_of_day")["initial_revenue"].sum()) / data.groupby("time_of_day")["initial_revenue"].sum()
python: revenue_per_agent = data["revenue"].sum() / data["agent_count"].max()
python: revenue_per_agent_by_reason = data.groupby("call_reason")["revenue"].sum() / data.groupby("call_reason")["agent_count"].max()
python: revenue_per_agent_by_time = data.groupby("time_of_day")["revenue"].sum() / data.groupby("time_of_day")["agent_count"].max()