python – Filter dataframe based on unique values in multiple columns and drop rows based on index

I’m wondering if there is a more efficient way of filtering a dataframe down based on certain unique values in several columns. Once I have it filtered down, I then want to extract keep one the largest value and I do this by dropping all indexes from the original dataframe. However, this process is slow and as the iterations and number of items in the dataframe increase the speed becomes more of an issue.

import pandas as pd
import numpy as np
import timeit


data_len = 1000
half = int(data_len/2)
fifth = int(data_len/5)
ans = ('Cat') * data_len
cols = ('White') * half + ('Black') * half
age = np.random.randint(1, 10, data_len)
breed = ('A') * fifth + ('B') * fifth + ('C') * fifth + ('D') * fifth + ('E') * fifth
weights = np.random.uniform(1, 100, data_len)
heights = np.random.uniform(1, 100, data_len)

df = pd.DataFrame(columns=('Animal', 'Color', 'Age', 'Breed', 'Weight', 'Height'))

df('Animal') = ans
df('Color') = cols
df('Age') = age
df('Breed') = breed
df('Weight') = weights
df('Height') = heights


def get_largest(df):
    drop_id = ()
    sort_cols = ('Weight', 'Height')
    for Animal in pd.unique(df('Animal')):
        animals_df = df.loc(np.in1d(df('Animal'), Animal))
        for Color in pd.unique(animals_df('Color')):
            color_df = animals_df.loc(np.in1d(animals_df('Color'), Color))
            for uid in pd.unique(color_df('Age')):
                age_df = color_df.loc(np.in1d(color_df('Age'), uid))
                for vic in pd.unique(age_df('Breed')):
                    breed_df = age_df.loc(np.in1d(age_df('Breed'), vic))
                    drop_id.extend(
                        breed_df.sort_values(by=sort_cols, ascending=(False) * len(sort_cols)).index(1:).values)
    df = df.drop(df.index(drop_id))
    return df

func = lambda: get_largest(df)
print(timeit.timeit(func, number=100))