我有以下数据:
data_SP = pd.read_csv(path_ServicePath, sep='\t', header=None)
data_SP.columns = ["Id#SP"]
print(data_SP)
IdSP
0 SH11
1 SH11
2 SH12
3 SH12
4 SH13
5 SH13
6 SH13
7 SH13
... ...
而且,
data_SH = pd.read_csv(path_ServiceHierarchy,sep='\t',header=None)
data_SH.columns = ["Id#SH", "ConnectionClient"]
print(data_SH)
IdSH ConnectionClient
0 SH11 CN01207507
1 SH12 CN01207509
2 SH13 CN01207539
3 SH14 CN01207542
4 SH15 CN01207564
... ...
实际上,我想计算data_SP
中出现data_SH
元素的次数。换句话说,data_SH. ['Id#SH']
中的每个单独的元素在data_SP
中重复了多少次。
例如:
SH11 = 2
SH12 = 2
SH13 = 4