I am trying to segment the dataframe where I only have a dataframe that contains certain words inside one of its columns and does not contain others.
For example
d = {'resolution' : ['replaced scanner', 'replaced the scanner for the user with a properly working one from the cage replaced the wire on the damaged one and stored it for later use','the scanner has been replaced and the station is working well now', 'replaced scanner screen']}
df_sample = pd.DataFrame(data=d)
keywords = ['replace', 'replaced', 'change', 'changed', 'swapped', 'deployed', 'scanner']
filtered_words = ['screen']
df_filtered = df_sample[(df_sample['resolution'].isin(keywords)) & (~df_sample['resolution'].isin(filtered_words))]
df_filtered.head()
I would expect to get
d = {'resolution' : ['replaced scanner', 'replaced the scanner for the user with a properly working one from the cage replaced the wire on the damaged one and stored it for later use','the scanner has been replaced and the station is working well now']}
df_filtered = pd.DataFrame(data=d)
But instead I just get an empty dataframe. Any suggestions are appreciated.