PYTHON我需要从行中删除一些字符

2024-05-05 17:13:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要从某些行中删除“-”: df:

description
- Fallo en el sensor del yaw
- Error enrollamiento máximo
Cannot couple without polo test

预期产出:

description
Fallo en el sensor del yaw
Error enrollamiento máximo
Cannot couple without polo test

Tags: testerrordescriptionsensorelenwithoutdel
1条回答
网友
1楼 · 发布于 2024-05-05 17:13:11

可以使用“replace方法将“-”替换为空字符串,如下所示-

df["description"].replace({"- ": ""}, inplace = True, regex = True)

请注意,您必须使用“-”而不是“-”,因为您的数据中有带尾随空格的“-”

相关问题 更多 >