数据框:
df = {'Client': ['A', 'A', 'A',
'B', 'B', 'B', 'B','B','B','B','B',
'C',
'D','D','D','D','D','D','D','D','D','D','D' ],
'Result': ['Covered', 'Customer Reject', 'Customer Timeout',
'Dealer Reject','Dealer Timeout','Done','Tied Covered','Tied Done','Tied Traded Away','Traded Away','No RFQ',
'No RFQ',
'Covered','Customer Reject','Customer Timeout','Dealer Reject','Dealer Timeout','Done','Tied Covered','Tied Done','Tied Traded Away','Traded Away','No RFQ']}
df = pd.DataFrame.from_dict(df)
print(df)
Client Result
0 A Covered
1 A Customer Reject
2 A Customer Timeout
3 B Dealer Reject
4 B Dealer Timeout
5 B Done
6 B Tied Covered
7 B Tied Done
8 B Tied Traded Away
9 B Traded Away
10 B No RFQ
11 C No RFQ
12 D Covered
13 D Customer Reject
14 D Customer Timeout
15 D Dealer Reject
16 D Dealer Timeout
17 D Done
18 D Tied Covered
19 D Tied Done
20 D Tied Traded Away
21 D Traded Away
22 D No RFQ
期望的输出:
我想添加两个使用每个返回分组结果的公式。因此,将有Total一行(每个客户端的所有结果的总和),但也有两个基于从每个客户端返回的分组值之和的公式(Pct_Calc_1和):Pct_Calc_2
Pct_Calc_1 = (Total_Result_Per_Client - Total_Dealer_Reject_Per_Client - Total_Dealer_Timeout_Per_Client) / (Total_Per_Client - Total_Customer_Reject_Per_Client)
Pct_Calc_2 = (Total – (Covered + Tied Covered) – Customer Reject – Dealer Reject – Dealer Timeout – (Traded Away + Tied Traded Away)) / (Total – Dealer Reject – Dealer Timeout)
如果需要更改原始分组来满足此额外输出,那么一切都很好。
FFIVE
相关分类