小编Lis*_*isa的帖子

Python: Check if string and its substring are existing in the same list

I've extracted keywords based on 1-gram, 2-gram, 3-gram within a tokenized sentence

list_of_keywords = []
for i in range(0, len(stemmed_words)):
    temp = []
    for j in range(0, len(stemmed_words[i])):
        temp.append([' '.join(x) for x in list(everygrams(stemmed_words[i][j], 1, 3)) if ' '.join(x) in set(New_vocabulary_list)])
    list_of_keywords.append(temp)
Run Code Online (Sandbox Code Playgroud)

I've obtained keywords list as

['blood', 'pressure', 'high blood', 'blood pressure', 'high blood pressure']
['sleep', 'anxiety', 'lack of sleep']
Run Code Online (Sandbox Code Playgroud)

How can I simply the results by removing all substring within the list and remain:

['high blood pressure']
['anxiety', …
Run Code Online (Sandbox Code Playgroud)

python nlp

12
推荐指数
1
解决办法
773
查看次数

根据值合并行(pandas 到 excel - xlsxwriter)- 加法

跟进这个问题

我想问我们是否可以合并多列中的行,即

在此输入图像描述

根据 @Dimitris Thomas 的回答,我将能够获得以下内容

在此输入图像描述

并想知道如何更新代码以获得:

在此输入图像描述

谢谢

pandas

4
推荐指数
1
解决办法
1397
查看次数

标签 统计

nlp ×1

pandas ×1

python ×1