看板 Python 關於我們 聯絡資訊
想請問一下 我想從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] -- Sent from my Android -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.122.53.22 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1446707507.A.1AC.html ※ 編輯: stba5328 (140.122.53.22), 11/05/2015 15:12:29
walelile: get_index()跟xlst = ... 不是在做同一件事嗎? 11/05 15:23