DEV Community

brhett
brhett

Posted on

Answer: Picking a variable's category from a dataframe

please try this:

import seaborn as sns

# Load the dataset
df = sns.load_dataset("tips")

# Filter the dataframe for 'Dinner' time
df_dinner = df[df['time'] == 'Dinner']

# Perform aggregation on the filtered dataframe
result = df_dinner.agg({'total_bill': ['sum', 'min', 'max', 'mean']})

# Display the result
print(result)

Top comments (0)