How do I drop a limited number of rows? So far my code drops every instance I give. So in the example below, every instance of 'dog' is dropped. However, I would like to drop a specified number of instances, so for example only drop 2 instances of dog, it would also be a benefit if the instances to drop were sampled at random.
num = [10, 20, 30, 10, 40, 50, 20, 60, 70, 20]
color = ['red', 'white', 'black', 'green', 'white', 'orange', 'white', 'black', 'blue', 'red']
animal = ['dog', 'cat', 'raccoon', 'gecko', 'bear', 'raccoon', 'dog', 'goat', 'goat', 'dog']
dict = {'Number': num, 'Color': color, 'Animal': animal}
df = pd.DataFrame(dict)
to_drop = ['dog']
trimmed_df = df[~df['Animal'].isin(to_drop)]