[問題] 刪除大量數據的速度問題

作者: stba5328 (St. Ba)   2015-11-05 15:11:44
想請問一下
我想從x, y兩個元素數量相等list當中,刪除所有值為-9999的項,
並且另一list同index的項目也要刪除,但因為list中大概有180萬筆,
-9999的聯集數量大概57萬筆,該如何加速以下的程序呢?
def get_index(a):
lst = [i for i, j in enumerate(a) if j == -9999]
return lst
indx = get_index(x)
indy = get_index(y)
indlst = list(set(indx) | set(indy))
xlst = [j for i, j in enumerate(x) if i not in indx]
ylst = [j for i, j in enumerate(y) if i not in indy]
作者: walelile (wakaka)   2015-11-05 15:23:00
get_index()跟xlst = ... 不是在做同一件事嗎?

Links booklink

Contact Us: admin [ a t ] ucptt.com