You seem to be looking at an enumeration. I assume you're using python? Is your enumeration fixed or does it need to be generated from the dataset? Does the order matter to you?

If the order doesn't matter, you might consider one-hot encoding instead of enumeration. Enumeration is great for changing descriptions like low, medium, high into numeric inputs.

Enumeration from inputs:

carnivore_to_index = {carnivore: i for i, carnivore in enumerate(sorted(df["carnivore"].unique()))}
df["carnivore_index"] = df["carnivore"].map(carnivore_to_index)

If you want to assign relative values to the carnivores, you can hard code your index map instead of generating it this way.

One-hot encoding carnivores:

encoded_carnivores = pd.get_dummies(df["carnivore"], prefix="carnivore")
df = pd.concat([df, encoded_carnivores], axis=1)