in my dataframe i have a column 'amenities' and for each row this column contains a list of amenities.
My goal is basically to manually one-hot-encode this, i dont think what ive done is the most efficient way to write this code as it takes a little bit of time to run.
`
for amenity in amenities_list:
amenities_df[amenity] = amenities_df['amenities'].apply(lambda x: 1 if amenity in str(x) else 0)
`
amenities_list is a list of all the amenities. The loop creates a new column for the amenity and then checks the amenities column and if that amenity is in the list then the individual column will show 1 otherwise 0.
I tried the above for loop but i'm thinking there's some better and more efficient way to preform the same action.
thanks