from langchain_core.tools import tool import pandas @tool def analyze_excel_file(file_path: str, query: str) -> str: """ Analyze an Excel file using pandas and answer a question about it. Args: file_path (str): the path to the Excel file. query (str): Question about the data """ try: file = pandas.read_excel(file_path) result = ( f"Excel file loaded with {len(file)} rows and {len(file.columns)} columns.\n" ) result += f"Columns: {', '.join(file.columns)}\n\n" result += "Summary statistics:\n" result += str(file.describe()) return result except Exception as e: return f"Error analyzing Excel file: {str(e)}"