A Python-based interactive data analysis tool that leverages local AI models (via Ollama) to perform intelligent data analysis on CSV files. This application allows users to ask natural language queries about their data and receive automated pandas-based analysis results.
- Interactive Data Analysis: Ask questions about your data in natural language
- Local AI Integration: Uses Ollama for local AI model inference
- CSV File Support: Automatically detects and loads CSV files from the
data/directory - Multiple AI Models: Choose from available local AI models
- Pandas Integration: Generates and executes pandas commands for data analysis
- User-Friendly Interface: Simple menu-driven interface for easy navigation
Before running this application, you need to have:
- Python 3.7+ installed on your system
- Ollama installed and running locally
- Download from: https://ollama.ai/
- Install and start the Ollama service
- At least one AI model pulled in Ollama (e.g.,
llama2,codellama,mistral)
-
Clone or download this repository to your local machine
-
Install Python dependencies:
pip install -r requirements.txt
-
Prepare your data:
- Create a
data/folder in the project directory - Place your CSV files in the
data/folder - The application will automatically detect available CSV files
- Create a
-
Start Ollama (if not already running):
ollama serve
-
Pull an AI model (if you haven't already):
ollama pull llama2 # or any other model like: # ollama pull codellama # ollama pull mistral
-
Start the application:
python main.py
-
Select an AI Model: Choose from available local models
-
Select a Dataset: Pick a CSV file from the
data/directory -
Analyze Data: Ask questions about your data in natural language
- "What is the average sales?"
- "Show me the top 5 highest values in the salary column"
- "Count the number of rows"
- "What is the correlation between age and salary?"
- "Group by department and show the mean salary"
data_analysis_agent/
├── main.py # Main application entry point
├── data_analyzer.py # Core data analysis logic
├── model_selection.py # AI model selection interface
├── ollama_client.py # Ollama API integration
├── csv_files.py # CSV file management
├── data_loader.py # Data loading utilities
├── requirements.txt # Python dependencies
├── data/ # Directory for CSV files
│ ├── sales_data.csv
│ ├── emp_data.csv
│ └── ...
└── README.md # This file
- Model Selection: The application connects to Ollama's API to discover available local AI models
- Data Loading: CSV files are automatically detected and loaded using pandas
- Query Processing: Natural language queries are sent to the selected AI model
- Code Generation: The AI model generates appropriate pandas commands
- Execution: The generated pandas code is executed on the dataset
- Results: Analysis results are displayed to the user
- CSV files only (placed in the
data/directory) - Files should have headers (column names)
- Standard CSV format with comma separators
-
"No AI models available"
- Ensure Ollama is running:
ollama serve - Pull at least one model:
ollama pull llama2
- Ensure Ollama is running:
-
"No CSV files found"
- Create a
data/folder in the project directory - Place your CSV files in the
data/folder
- Create a
-
Connection errors
- Verify Ollama is running on
http://localhost:11434 - Check if the Ollama service is accessible
- Verify Ollama is running on
-
Analysis errors
- Ensure your CSV files have proper headers
- Check that column names in queries match your data
- Verify data types are appropriate for the analysis
pandas==2.3.1- Data manipulation and analysisrequests==2.32.4- HTTP requests for Ollama API
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to submit issues, feature requests, or pull requests to improve this data analysis agent.
Note: This application requires Ollama to be running locally with at least one AI model installed. Make sure you have sufficient system resources for running local AI models.