Freddolin's picture
Create tools/excel_tool.py
9779920 verified
raw
history blame
347 Bytes
import pandas as pd
def analyze_excel(filepath: str) -> str:
df = pd.read_excel(filepath)
# Summing up all numeric food items if 'category' exists
if 'category' in df.columns and 'amount' in df.columns:
food_sales = df[df['category'].str.lower() == 'food']
return f"{food_sales['amount'].sum():.2f}"
return "0.00"