[英]How to add each element of a list to a new list using Python?
因此,閱讀本文,我相信所需的 output 只是一個標簽數組。 如果是這樣,這應該工作。
hashtags2 = []
for sublist in hashtags:
hashtags2.extend(sublist)
.extend() 方法本質上是將新列表添加到當前列表中,例如:
list1 = [1,2,3]
list2 = [4,5,6]
list1.extend(list2)
print(list1) # This will print [1,2,3,4,5,6]
然后,您可以提前 go 並將您的標簽兩個列表添加到 dataframe 中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.