1 回答

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超9個(gè)贊
您可以使用嵌套列表理解來(lái)執(zhí)行此操作。循環(huán)訪問(wèn)列表的每個(gè)子列表,循環(huán)訪問(wèn)每個(gè)元組,檢查元組是否包含 .nan
[[tup for tup in sublist if not any(map(math.isnan, tup))] for sublist in tmp]
# returns:
[[(0, 1.0),
(10, 1.0),
(20, 1.0),
(30, 1.0),
(40, 0.9808612440191388),
(50, 0.9719298245614035),
(60, 0.9712918660287081),
(70, 0.8947368421052632),
(80, 0.956140350877193),
(90, 0.6140350877192983)],
[(0, 0.9635627530364372),
(10, 1.0),
(20, 0.9924812030075187),
(30, 1.0),
(40, 0.9808612440191388),
(50, 0.9508771929824561),
(60, 0.9617224880382775),
(70, 0.8173374613003096),
(80, 0.8464912280701754),
(90, 0.5614035087719298)]]
添加回答
舉報(bào)