LonghaoWang's picture
Unit 4 tool agent
b64d2eb verified
Raw History Blame Contribute Delete
562 Bytes
"""Excel sales aggregation."""
from __future__ import annotations
from pathlib import Path
from typing import Optional
import pandas as pd
DRINK_COLS = {"soda", "drink", "drinks", "beverage", "beverages", "coffee", "tea"}
def total_food_sales_usd(path: Path) -> Optional[str]:
df = pd.read_excel(path)
numeric = df.select_dtypes(include="number")
food_cols = [c for c in numeric.columns if str(c).strip().lower() not in DRINK_COLS]
if not food_cols:
return None
total = float(df[food_cols].sum().sum())
return f"{total:.2f}"