擅长:python、mysql、java
<p>我为你做这个。。。没有测试</p>
<pre><code>def find_intrastr_column_df(df, column_name, list_of_str_to_find):
"""
Loop in a pandas dataframe, trying to find all rows
that contains the listed words in a particular column and
return a selected dataframe only with the rows founded.
df: Pandas Dataframe
column_name: String. Columns name
list_of_str_to_find: List. List of String of words to find.
"""
list_rows_find = []
for index, row in df.iterrows():
cell_value = row[column_name]
# ignore nan values
if cell_value != cell_value:
break
else:
pass
found = True
for str in list_of_str_to_find:
if str not in cell_value:
found = False
break
else:
pass
if found:
list_rows_find.append(index)
else:
pass
df_selected = df.loc[list_rows_find,:]
return df_selected
</code></pre>