<p>这应该管用</p>
<p>要么全部改为大写或小写,因为它是区分大小写的。小心点,因为标点符号可能也需要处理</p>
<pre><code>import pandas as pd
keywords=["i can help you with that", "i can surely help you with that", "i can check and help you with that", "i will be more than happy to help you", "let me assist you on this", "to assist you better"]
############## Read in excel file ##########################
col1 = ["agent enters(as arrin)",
"",
"I'll be happy to assist you. Give me a moment to review your request.",
"I see that the light in your Modem is Blinking Red. Am I right ?",
"Thank you for the detailed information.",
"Please do not worry.",
"Don't worry johny. I can help you with that.",
"Let me connect this chat to the concern team to help you out with this, Please stay connected."]
col2 = ['2018-10-14 21:16:58',
'2018-10-14 21:17:00',
'2018-10-14 21:17:40',
'2018-10-14 21:18:25',
'2018-10-14 21:19:39',
'2018-10-14 21:19:43',
'2018-10-14 21:21:04',
'2018-10-14 21:22:00']
df = pd.DataFrame()
df['col1'] = col1
df['col2'] = col2
#####################################################
# lower case keywords and col1 strings
lower_keywords = [x.lower() for x in keywords]
df['low_col1'] = df['col1'].str.lower()
df_filter = df[df['low_col1'].str.contains('|'.join(lower_keywords))]
print (df_filter['col2'])
</code></pre>
<p>输出:</p>
<pre><code>In [38]: print (df_filter['col2'])
Out [38]: 6 2018-10-14 21:21:04
Name: col2, dtype: object
</code></pre>