excel - 句子标点返回 True-Spacy
问题描述
我正在使用熊猫编写包含句子的逗号以表现出色。
lists = [sent for sent in doc.sents if ',' in sent.string.lower()]
发现,我可以在 excel 中为它返回 True 或 False。
=ISNUMBER(SEARCH(",", A1))
我使用下面的代码来提取句子并将其列为 Excel 中的行
sentences = [sent.string.strip() for sent in doc.sents]
预计出炉:
Sentence IS_comma_sent
This sentence contains no comma. False
There is a , in this sentence. True
关于如何在熊猫中做到这一点的任何建议。
解决方案
IIUC str.包含
df['Is_comma_sent']=df['Sentence'].str.contains(',')
推荐阅读
- python - KeyError:标准 gdp 学习代码中的 `INEQUALITY`
- swift - MapView用户位置落户
- laravel - 使用 JWT auth 测试端点时如何发出多个请求
- javascript - FabricJS Canvas 上的强制更新
- java - 多次调用platform.runlater javafx
- python - 如何将3维图片灰度的形状更改为4维
- laravel - Laravel 7.x:PDOException:SQLSTATE [22P02]:无效的文本表示:7 错误:bigint 类型的输入语法无效
- scala - 如何在scala中解析地图列表
- swift - 如何在更改嵌套数组时重新渲染?
- python - 在 Windows 上获取本地时区名称(Python 3.9 zoneinfo)