I have a column with list of string in every row(no of strings are different). I have created few categories based on the strings in columns and now i want to check if category is available i will place one for the category.
list cusine_type i am using is
['north indian','chinese','south indian','continental','cafe','fast food','beverages','italian','american','desserts','rest_cuisines']
I have written a code, which is basically 2 forloops supported by few if loop to support the logic but this code is quite slow. i need some solution which is less time consuming.
for i in temp.index:
split = temp['cuisines'].iloc[i].split(',')
for string in split:
string=string.strip()
if string in cusine_type:
if temp.loc[i,string]==0:
temp.loc[i,string]=1
else:
temp.loc[i,'rest_cusines']=1
I want output to be like this table:
