看板
[ Python ]
討論串[問題] 詢問list如行相加
共 6 篇文章
內容預覽:
hi 我想詢問list若有重複的標籤該如何相加. 我有三組list,內容為個人所收藏的標籤與其收藏次數,如下所示:. link_a = ['a','b','c']. bookmark_a = ['1','2','3']. link_b = ['b','c']. bookmark_c = ['4','
(還有215個字)
內容預覽:
可以試試collections.Counter 不過首先bookmark_x是數字比較好處理. from collections import Counter. link_a = ['a','b','c']. bookmark_a = [1,2,3]. link_b = ['b','c']. boo
(還有1127個字)
內容預覽:
先轉換成 dict , 再用set合併重複的key. link_a = ['a','b','c']. bookmark_a = ['1','2','3']. link_b = ['b','c']. bookmark_b = ['4','5']. link_c = ['a']. bookmark_c
(還有417個字)
內容預覽:
假設你的收藏次數是數字:. >>> import pandas as pd. >>> a = pd.Series(bookmark_a, link_a). >>> b = pd.Series(bookmark_b, link_b). >>> c = pd.Series(bookmark_c, lin
(還有30個字)