[英]How to find the most frequent places in list for certain list of elements?
這是使用 plot 對其進行簡單直觀表示:
import matplotlib.pyplot as plt
lst = [8,6,3,7,1,8,8,9,2,0,5,4,7,9,2,8,2,5,5,6,3,0,1,7,9,2,9,6,7,0,5,2,7,4,5,6,2,1,9,0,3,1,3,9,4,9,2,7,5,9,0,5,2,1,8,6,4]
target = [1,4,3,8]
result = [0]*len(lst)
for i in range(len(lst)):
if lst[i] in target:
result[i] = 1
plt.step(range(len(lst)), result)
plt.show()
給出以下,相當容易分析的結果:
x 軸表示列表中的索引,1 表示在目標列表中,0 表示不在目標列表中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.