I am trying to search a Pandas dataframe with a list in Python 3. For clarity I am on a Windows machine with python 3.8.
I have an excel file that I am looking for certain keywords in a notes column and then I want the program to return another column that contains an id number. Currently my code does this by putting the excel data into a pandas dataframe and then checking a string variable with str.contains but I have more than one keyword I want to search and I am not sure how to do that.
Here is my code so far:
import pandas as pd
searchWord1 = 'Honda'
searchWord2 = 'honda'
searchWord3 = 'Toyota'
searchWord4 = 'toyota'
searchWord5 = '350'
df = pd.read_excel('data.xlsx',sheet_name='Sheet1')
df2 = (df[df['Notes'].str.contains(searchWord1)])
print(df2['id_number'])
I have tried creating a list, using a for loop and iterating through it but no luck, maybe I am just doing it wrong? I'm pretty new to python and pandas so any help would be greatly appreciated, thank you.