import pandas as pd
# Sample DataFrame
data = {
'Store': ['A', 'A', 'B', 'B', 'A', 'B'],
'Product': ['Apple', 'Banana', 'Apple', 'Banana', 'Apple', 'Banana'],
'Sales': [100, 150, 200, 100, 120, 180],
'Quantity': [10, 20, 30, 40, 15, 35]
}
df = pd.DataFrame(data)
display(df)
# Grouping by 'Store' and applying different aggregation functions
agg_dict = {
'Sales': 'sum', # Sum the 'Sales' column
'Quantity': 'mean' # Find the mean of the 'Quantity' column
}
result = df.groupby('Store').agg(agg_dict).reset_index()
print("\n",result)