I'm trying to find Names that contain the letters by user input. In this case, finding Names in the Name
column that contain 'a' and 'i' however getting an error:
data = {'Name': ['Aerial', 'Tom', 'Amie', 'Anuj'],
'Age': [27, 24, 22, 32],
'Address': ['pennsylvania', 'newyork', 'newjersey', 'delaware'],
'Qualification': ['Msc', 'MA', 'MCA', 'Phd']}
df = pd.DataFrame(data)
df["Name"] = df["Name"].str.lower()
print(df)
letters_in = input('Words in Name Column that contain these letters: \n ').split()
new_output = df.loc[df['Name'].str.contains(letters_in, case=False)]
Code run:
Words in Name Column that contain these letters:
>? a e
ERROR:
TypeError: unhashable type: 'list'
Ideal Output (as dataframe):
Aerial
Amie