So, I have dataframe like this,
data = {
"properties": ["FinancialOffice","Gas Station", "Office", "K-12 School", "Commercial, Office"],
}
df = pd.DataFrame(data)
This is my list,
proplist = ["Office","Other - Mall","Gym"]
what I am trying to do is using the list I am trying to find out which words exactly matches with the dataframe column and for each word from the dataframe I need to assign a Boolean true/false value or 0/1. It has to be a exact match.
Output like this,
properties flag
FinancialOffice FALSE
Gas Station FALSE
Office TRUE
K-12 School FALSE
Commercial, Office TRUE
So, It returns TRUE for only "Office" because it is the exact match from the list. FinancialOffice is not because it is not in the list. Also, For the last one Commercial, Office it is TRUE because Office is found in the list even though Commercial not. So, even one of them is present it will be TRUE.
df["flag"] = df["properties"].isin(proplist)
Above code works fine to assign a boolean true/false but It returns FALSE for the last one(Commercial,Office) as it tries to find the exact match.
Any help is appreciated.