我有一个包含字符串的列的框架.我想修剪列中的字符串,以便在给定单词出现first次后删除所有内容.这些词在这个列表中:
words_to_trim_after = ['test', 'hello', 'very good']
所以如果我有一个像下面这样的框架
df = pd.DataFrame({'a':['test this is a test bla bla', 'hello bla bla this is a test', 'very good qwerty this is nice']})
我想以
df_end = pd.DataFrame({'a':['test', 'hello', 'very good']})