我有一列文本。如何剪切每个文本在术语show less
之后的部分?
例如:
df = pd.DataFrame({'col':['hi there see less new way is comming','today is summer, see less , is a lovely day']})
看起来像:
col
'hi there see less new way is comming'
'today is summer, see less , is a lovely day'
输出:
col
'hi there'
'today is summer,'
最佳答案
您可以使用str.split
在see less
上进行分割,然后使用str切片来获取第一部分。
df['col'] = df['col'].str.split('see less').str[0]
输出:
col
0 hi there
1 today is summer,
关于python - 如何剪切特定单词后的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70687083/