我想为 df2 中的数据连续分配一个特定的 ID,并基于此,ID 我想转换它在 df1 中的所有出现。我写的代码需要很多时间来执行。有没有其他办法?
for i in range (0,35261):
for j in range (0,54793):
if (df2.V_ID[i] == df.V_ID[j]):
df.V_ID[j] = i
df 的示例数据:
time IP1 IP2 GETVIDEO V_ID IP3
0 2008-03-11 17:28:17 63.22.65.77 205.181.173.92 GETVIDEO ORDhCi6JQaY&signature 254.212.25.169
1 2008-03-11 17:28:20 63.22.65.94 35.139.184.95 GETVIDEO xEcFchOvj4Y&signature 254.212.19.255
2 2008-03-11 17:28:22 63.22.65.73 35.139.176.183 GETVIDEO z-oBoCMSfbw&signature 254.212.19.196
3 2008-03-11 17:28:23 63.22.65.73 102.15.230.123 GETVIDEO pSo-_TavE1U&signature 254.212.25.206
4 2008-03-11 17:28:23 63.22.65.77 102.15.134.225 GETVIDEO kHtaORb0LUk&signature 254.212.22.122
5 2008-03-11 17:28:23 63.22.65.77 102.15.111.222 GETVIDEO t7qjlPPmeJE&origin 105.136.78.115
6 2008-03-11 17:28:27 63.22.65.73 35.139.31.8 GETVIDEO 2UPaRi0WY7c&origin 105.136.78.115
7 2008-03-11 17:28:28 63.22.65.73 102.15.143.68 GETVIDEO lAzrUxpybs0&signature 254.212.21.130
8 2008-03-11 17:28:30 63.22.65.73 205.181.139.118 GETVIDEO J_KKyw8V-l0&origin 105.136.78.115
9 2008-03-11 17:28:31 63.22.65.73 102.15.143.20 GETVIDEO xnsPfRdSU0Q&origin 105.136.78.115
10 2008-03-11 17:28:34 63.22.65.94 102.15.141.151 GETVIDEO qDKx6CkQM04&origin 105.136.78.115
df2 的示例数据:
V_ID count
0 2UPaRi0WY7c&origin 768
1 t7qjlPPmeJE&origin 142
2 CKrTlXN9-iE&origin 107
3 IZtPejST9IQ&origin 103
4 FKb3qRljGBc&origin 93
5 LcM0OT6mnqA&origin 67
6 7sei-eEjy4g&origin 62
7 qDKx6CkQM04&origin 53
8 4rb8aOzy9t4&origin 46
9 wjv4Fp7GiGk&origin 46
10 SKDXBvPIepI&sign 44
慕斯709654
相关分类