# Google Pandas Agent
A Google-native alternative to LangChain's create_pandas_dataframe_agent, powered by Google's Gemini models and LangGraph.
## Features
- Query pandas DataFrames using natural language
- Powered by Google's Gemini models
- Simple, intuitive interface
- Type-safe implementation
- Comprehensive error handling
- Support for multiple DataFrames
## Installation
```bash
pip install google-pandas-agent
```
## Requirements
- Python >= 3.10
- pandas >= 2.2
- google-generativeai >= 0.8.5
- langgraph >= 0.3.21
## Quick Start
```python
import pandas as pd
import google.generativeai as genai
from google_pandas_agent import create_pandas_dataframe_agent
# Initialize Gemini
genai.configure(api_key='your-api-key') # Get your API key from Google Cloud Console
model = genai.GenerativeModel('gemini-pro')
# Create a sample DataFrame
df = pd.DataFrame({
'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 35],
'City': ['New York', 'London', 'Paris']
})
# Create the agent
agent = create_pandas_dataframe_agent(model, df)
# Ask questions about your data
response = agent.chat("What is the average age?")
print(response)
# You can also use multiple DataFrames
df2 = pd.DataFrame({
'City': ['New York', 'London', 'Paris'],
'Country': ['USA', 'UK', 'France']
})
agent = create_pandas_dataframe_agent(model, [df, df2])
response = agent.chat("Show me people's names along with their countries")
print(response)
```
## API Reference
### create_pandas_dataframe_agent
```python
def create_pandas_dataframe_agent(
llm: genai.GenerativeModel,
df: Union[pd.DataFrame, List[pd.DataFrame]],
*,
verbose: bool = False,
allow_dangerous_code: bool = False,
**kwargs,
) -> AgentExecutor
```
Creates an agent that can answer questions about pandas DataFrames.
#### Parameters
- `llm`: A Gemini model instance (must be initialized with `genai.GenerativeModel`)
- `df`: A pandas DataFrame or list of DataFrames
- `verbose`: Enable verbose output (default: False)
- `allow_dangerous_code`: Allow potentially unsafe imports in the Python REPL (default: False)
- `**kwargs`: Additional arguments passed to the executor
#### Returns
An `AgentExecutor` instance that can process natural language queries about the DataFrame(s)
### AgentExecutor
The main class for executing queries against DataFrames.
#### Methods
- `chat(question: str) -> str`: Process a natural language query and return the response
- `run(question: str) -> str`: Alias for chat()
- `invoke(state: dict) -> dict`: Advanced method for custom state handling
## Common Issues and Solutions
1. **Import Error**: If you get an error about missing dependencies, make sure you have all required packages installed:
```bash
pip install "google-pandas-agent[all]"
```
2. **API Key Error**: Make sure to configure your Google API key before creating the model:
```python
genai.configure(api_key='your-api-key')
```
3. **Model Error**: Ensure you're using the correct model name ('gemini-pro'):
```python
model = genai.GenerativeModel('gemini-pro')
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Authors
- Ariamehr Maleki (ariamehr.mai@gmail.com)
- Frank Roh (frankagilepm@gmail.com)
- Darren North (denorth222@gmail.com)
Raw data
{
"_id": null,
"home_page": null,
"name": "google-pandas-agent",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "gemini, pandas, agent, langgraph, google-generativeai, dataframe, analysis",
"author": null,
"author_email": "Ariamehr Maleki <ariamehr.mai@gmail.com>, Frank Roh <frankagilepm@gmail.com>, Darren North <denorth222@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/32/7e/435ae0fb14f9e646f6e169a388a50836f465fb3245ad34d9e31a14003a85/google_pandas_agent-1.0.3.tar.gz",
"platform": null,
"description": "# Google Pandas Agent\r\n\r\nA Google-native alternative to LangChain's create_pandas_dataframe_agent, powered by Google's Gemini models and LangGraph.\r\n\r\n## Features\r\n\r\n- Query pandas DataFrames using natural language\r\n- Powered by Google's Gemini models\r\n- Simple, intuitive interface\r\n- Type-safe implementation\r\n- Comprehensive error handling\r\n- Support for multiple DataFrames\r\n\r\n## Installation\r\n\r\n```bash\r\npip install google-pandas-agent\r\n```\r\n\r\n## Requirements\r\n\r\n- Python >= 3.10\r\n- pandas >= 2.2\r\n- google-generativeai >= 0.8.5\r\n- langgraph >= 0.3.21\r\n\r\n## Quick Start\r\n\r\n```python\r\nimport pandas as pd\r\nimport google.generativeai as genai\r\nfrom google_pandas_agent import create_pandas_dataframe_agent\r\n\r\n# Initialize Gemini\r\ngenai.configure(api_key='your-api-key') # Get your API key from Google Cloud Console\r\nmodel = genai.GenerativeModel('gemini-pro')\r\n\r\n# Create a sample DataFrame\r\ndf = pd.DataFrame({\r\n 'Name': ['Alice', 'Bob', 'Charlie'],\r\n 'Age': [25, 30, 35],\r\n 'City': ['New York', 'London', 'Paris']\r\n})\r\n\r\n# Create the agent\r\nagent = create_pandas_dataframe_agent(model, df)\r\n\r\n# Ask questions about your data\r\nresponse = agent.chat(\"What is the average age?\")\r\nprint(response)\r\n\r\n# You can also use multiple DataFrames\r\ndf2 = pd.DataFrame({\r\n 'City': ['New York', 'London', 'Paris'],\r\n 'Country': ['USA', 'UK', 'France']\r\n})\r\n\r\nagent = create_pandas_dataframe_agent(model, [df, df2])\r\nresponse = agent.chat(\"Show me people's names along with their countries\")\r\nprint(response)\r\n```\r\n\r\n## API Reference\r\n\r\n### create_pandas_dataframe_agent\r\n\r\n```python\r\ndef create_pandas_dataframe_agent(\r\n llm: genai.GenerativeModel,\r\n df: Union[pd.DataFrame, List[pd.DataFrame]],\r\n *,\r\n verbose: bool = False,\r\n allow_dangerous_code: bool = False,\r\n **kwargs,\r\n) -> AgentExecutor\r\n```\r\n\r\nCreates an agent that can answer questions about pandas DataFrames.\r\n\r\n#### Parameters\r\n\r\n- `llm`: A Gemini model instance (must be initialized with `genai.GenerativeModel`)\r\n- `df`: A pandas DataFrame or list of DataFrames\r\n- `verbose`: Enable verbose output (default: False)\r\n- `allow_dangerous_code`: Allow potentially unsafe imports in the Python REPL (default: False)\r\n- `**kwargs`: Additional arguments passed to the executor\r\n\r\n#### Returns\r\n\r\nAn `AgentExecutor` instance that can process natural language queries about the DataFrame(s)\r\n\r\n### AgentExecutor\r\n\r\nThe main class for executing queries against DataFrames.\r\n\r\n#### Methods\r\n\r\n- `chat(question: str) -> str`: Process a natural language query and return the response\r\n- `run(question: str) -> str`: Alias for chat()\r\n- `invoke(state: dict) -> dict`: Advanced method for custom state handling\r\n\r\n## Common Issues and Solutions\r\n\r\n1. **Import Error**: If you get an error about missing dependencies, make sure you have all required packages installed:\r\n ```bash\r\n pip install \"google-pandas-agent[all]\"\r\n ```\r\n\r\n2. **API Key Error**: Make sure to configure your Google API key before creating the model:\r\n ```python\r\n genai.configure(api_key='your-api-key')\r\n ```\r\n\r\n3. **Model Error**: Ensure you're using the correct model name ('gemini-pro'):\r\n ```python\r\n model = genai.GenerativeModel('gemini-pro')\r\n ```\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the LICENSE file for details.\r\n\r\n## Authors\r\n\r\n- Ariamehr Maleki (ariamehr.mai@gmail.com)\r\n- Frank Roh (frankagilepm@gmail.com)\r\n- Darren North (denorth222@gmail.com) \r\n",
"bugtrack_url": null,
"license": null,
"summary": "Google\u2011native alternative to LangChain's create_pandas_dataframe_agent",
"version": "1.0.3",
"project_urls": {
"Documentation": "https://github.com/yourusername/google-pandas-agent#readme",
"Homepage": "https://github.com/yourusername/google-pandas-agent",
"Issues": "https://github.com/yourusername/google-pandas-agent/issues",
"Repository": "https://github.com/yourusername/google-pandas-agent.git"
},
"split_keywords": [
"gemini",
" pandas",
" agent",
" langgraph",
" google-generativeai",
" dataframe",
" analysis"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e2442ffd0c25b301c000d5ac2ba0c77177dc9ff5d53063dfd727baaa9444e001",
"md5": "dbfab8f793c39000f760b04a86667b18",
"sha256": "7da8c652880e2fbb5b596bb4ad810d55b30e2797abff8889cef919dc16beb072"
},
"downloads": -1,
"filename": "google_pandas_agent-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dbfab8f793c39000f760b04a86667b18",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 8671,
"upload_time": "2025-04-21T01:13:17",
"upload_time_iso_8601": "2025-04-21T01:13:17.181195Z",
"url": "https://files.pythonhosted.org/packages/e2/44/2ffd0c25b301c000d5ac2ba0c77177dc9ff5d53063dfd727baaa9444e001/google_pandas_agent-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "327e435ae0fb14f9e646f6e169a388a50836f465fb3245ad34d9e31a14003a85",
"md5": "7893e06e60ce867d8ced3b01687b478f",
"sha256": "3f6ef84a44a7b61b5f04cdfce795ba7a2a6b0bfff9cd1dd12d2f67d2f60f2720"
},
"downloads": -1,
"filename": "google_pandas_agent-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "7893e06e60ce867d8ced3b01687b478f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 8368,
"upload_time": "2025-04-21T01:13:18",
"upload_time_iso_8601": "2025-04-21T01:13:18.661069Z",
"url": "https://files.pythonhosted.org/packages/32/7e/435ae0fb14f9e646f6e169a388a50836f465fb3245ad34d9e31a14003a85/google_pandas_agent-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-04-21 01:13:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "google-pandas-agent#readme",
"github_not_found": true,
"lcname": "google-pandas-agent"
}