Searching for specific strings in a column
Budget: €8 – €30 EUR
animal = ['bird', 'rabit', 'rat', 'bat']
df (see photo): first dataframe is the current one, the second one is the desired dataframe which contains an extra column (sort)
What I want to do is to look for the items of the list animal in multiple columns of the df. If one of the items is mentioned in one of the columns, I want it to be added to a new column in the dataframe. If none of them is present in the column, it should return NaN in the new column. If more than one item matches, the two should be added to the new column. The items could be written as a whole word like 'bird' or among other text like 'birdstrike'. In both cases, only bird should be added to the new column
df (see photo): first dataframe is the current one, the second one is the desired dataframe which contains an extra column (sort)
What I want to do is to look for the items of the list animal in multiple columns of the df. If one of the items is mentioned in one of the columns, I want it to be added to a new column in the dataframe. If none of them is present in the column, it should return NaN in the new column. If more than one item matches, the two should be added to the new column. The items could be written as a whole word like 'bird' or among other text like 'birdstrike'. In both cases, only bird should be added to the new column