File size: 347 Bytes
9779920
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
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"