【发布时间】:2020-08-07 13:05:15
【问题描述】:
我有一个代表库的 pandas 数据框。这些列代表元数据,例如作者、标题、年份和文本。文本列包含带有书籍文本的列表,其中每个列表元素代表书中的一个句子(见下文)
Author Title Text
0 Smith ABC ["This is the first sentence", "This is the second sentence"]
1 Green XYZ ["Also a sentence", "And the second sentence"]
我想对句子进行一些 NLP 分析。对于个别示例,我将使用列表比较,但是如何以最 Pythonic 的方式对列使用列表比较?
我想做的是例如使用包含单词 "the" 的句子列表创建一个新列,例如在此示例中:How to test if a string contains one of the substrings in a list, in pandas?
但是,他们使用带有字符串列而不是列表列的数据框。
【问题讨论】: