Spaces:
Build error
Build error
| from langchain_core.tools import tool | |
| import pandas | |
| def analyze_csv_file(file_path: str, query: str) -> str: | |
| """ | |
| Analyze a CSV file using pandas and answer a question about it. | |
| Args: | |
| file_path (str): the path to the CSV file. | |
| query (str): Question about the data | |
| """ | |
| try: | |
| file = pandas.read_csv(file_path) | |
| result = f"CSV 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 CSV file: {str(e)}" |