【Python】客服系统并发量统计

该博客介绍了如何使用Python从MySQL数据库中提取客服消息明细表数据,通过分钟分组和计算工单跨区时长,统计9:00~23:00期间每隔10分钟的并发量。内容包括调用数据库包,数据提取,数据处理和并发量计算的详细步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

假设,客服值班时间9:00~23:00,需要统计这个时间段内每隔10分钟的并发量。客服信息表存储的数据库是MySQL数据库。

客服消息明细表

message_record table

id empid name first_msg_time last_msg_time date
20202020 100200300 韩梅 2020-02-13 09:01:04 2020-02-13 18:17:19 2020-02-13
20202021 100200302 李雷 2020-02-13 09:20:28 2020-02-13 22:02:46 2020-02-13

第一步:调用包

import pymysql
import pandas as pd
import datetime
from collections import Counter
from tqdm import tqdm_notebook

第二步:提取数据

sql = '''
SELECT 
id,
first_msg_time , 
year(date) as 'year',
month(date) as 'month',
day(date) as 'day',
hour(first_msg_time ) as 'first_msg_hour',
MINUTE(first_msg_time ) as 'first_msg_min',
last_msg_time,
hour(last_msg_time) as 'last_msg_hour',
MINUTE(last_msg_time) as 'last_msg_day',
day(last_msg_time) as 'day'   # 获取工单结束日期,判断是否有跨天工单
FROM mes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值