我想在以下条件下使用pandas中的sql操作count, groupby, max
.
我的数据帧df
call_count Date Call Received Appointments
1 5/21/2021 Y N
2 5/21/2021 Y N
3 5/21/2021 Y N
1 5/22/2021 Y Y
2 5/22/2021 Y N
1 5/23/2021 N N
我想将这些数据分组到Date
以下,计算最大值call_count
,并计算Call Received
和Appointment
中的Y
和N
.
预期输出为:
Total_call_count Date Total Received Call Total Appointments
3 5/21/2021 3 0
2 5/22/2021 2 1
1 5/23/2021 0 0