Replace a value in a column if that value appears only once
It is easier if you store the value count separately to avoid redoing it inside the apply loop. You can do it like this:

food_count = data["food_group"].value_counts()
data["food_group"] = data["food_group"].apply(lambda x: "other" if food_count[x]==1 else x)