|
我有以下的数据,导入到pandas的same_freq_ho_pd里面了(有389行),想根据d_eci查找,修改d_mod3_value的值,修改后还有统计等功能。我先用下面的代码对d_eci的行生成一个列表。然后根据这个列表去作为loc的依据进行赋值。#生成某个d_eci的所在行清单
d_eci_dic={}
def fuzhi_d_flage(d_cell,cell):
if d_cell==cell:
return True
else:
return False
for i in range(0,cell_num):
eci = plan_site_pd.iloc[i, 2]
d_eci_df=same_freq_ho_pd.apply(lambda x: fuzhi_d_flage(x.d_eci, eci), axis=1)
d_eci_dic[eci]=d_eci_df
然后用下面对same_freq_ho_pd的赋值操作:
same_freq_ho_pd.loc[d_eci_dic[cell1],"d_mod3_value"] = cell1_mod3
能够执行,但感觉速度比较慢,因为我这个赋值会要操作几万-几百万次,所以希望速度能够尽量加快,不知道各位高手有没有建议! | s_eci | d_eci | ho_num | pci_x | pci_y | s_mod3_value \ | d_mod3_value | 0 | 2168271 | 2132511 | 0 | 347 | 55 | 2 | 1 | 1 | 2168271 | 2132512 | 0 | 347 | 54 | 2 | 0 | 2 | 2168271 | 2133371 | 1757.167 | 347 | 21 | 2 | 0 | 3 | 2168271 | 2133372 | 187.3333 | 347 | 23 | 2 | 2 | 4 | 2168271 | 2158461 | 0 | 347 | 63 | 2 | 0 | 5 | 2168271 | 2158511 | 0 | 347 | 70 | 2 | 1 | 6 | 2168271 | 2158512 | 0 | 347 | 71 | 2 | 2 | 7 | 2168271 | 2168171 | 0 | 347 | 279 | 2 | 0 | 8 | 2168271 | 2168172 | 527.8333 | 347 | 280 | 2 | 1 | 9 | 2168271 | 2168272 | 4492.167 | 347 | 345 | 2 | 0 | 10 | 2168271 | 2170611 | 320 | 347 | 321 | 2 | 0 | 11 | 2168271 | 2170612 | 1748.167 | 347 | 322 | 2 | 1 | 12 | 2168271 | 2170613 | 1 | 347 | 323 | 2 | 2 | 13 | 2168271 | 2216893 | 0 | 347 | 336 | 2 | 0 | 14 | 2168271 | 2252181 | 49.33333 | 347 | 96 | 2 | 0 | 15 | 2168271 | 2252183 | 19.16667 | 347 | 98 | 2 | 2 | 16 | 2168271 | 2252381 | 34.33333 | 347 | 331 | 2 | 1 | 17 | 2168271 | 2252383 | 0 | 347 | 330 | 2 | 0 | 18 | 2168271 | 2252521 | 0 | 347 | 31 | 2 | 1 | 19 | 2168271 | 2252541 | 1373.5 | 347 | 318 | 2 | 0 | 20 | 2168271 | 2252542 | 73145.5 | 347 | 319 | 2 | 1 | 21 | 2168271 | 2257772 | 0 | 347 | 177 | 2 | 0 | 22 | 2168271 | 420781131 | 5946.833 | 347 | 189 | 2 | 0 | 23 | 2168271 | 420781132 | 137.5 | 347 | 190 | 2 | 1 | 24 | 2168271 | 420781133 | 0 | 347 | 188 | 2 | 2 | 25 | 2168272 | 2132511 | 14.5 | 345 | 55 | 0 | 1 | 26 | 2168272 | 2132512 | 465.6667 | 345 | 54 | 0 | 0 | 27 | 2168272 | 2133322 | 0 | 345 | 73 | 0 | 1 |
| | | | | | | |
|
|