llama-index-readers-pandas-ai


Namellama-index-readers-pandas-ai JSON
Version 0.4.1 PyPI version JSON
download
home_pageNone
Summaryllama-index readers pandas_ai integration
upload_time2024-11-18 16:11:53
maintainerjerryjliu
docs_urlNone
authorYour Name
requires_python<4.0,>=3.9
licenseMIT
keywords ai pandas
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pandas AI Loader

```bash
pip install llama-index-readers-pandas-ai
```

This loader is a light wrapper around the `PandasAI` Python package.

See here: https://github.com/gventuri/pandas-ai.

You can directly get the result of `pandasai.run` command, or
you can choose to load in `Document` objects via `load_data`.

## Usage

```python
from pandasai.llm.openai import OpenAI
import pandas as pd

# Sample DataFrame
df = pd.DataFrame(
    {
        "country": [
            "United States",
            "United Kingdom",
            "France",
            "Germany",
            "Italy",
            "Spain",
            "Canada",
            "Australia",
            "Japan",
            "China",
        ],
        "gdp": [
            21400000,
            2940000,
            2830000,
            3870000,
            2160000,
            1350000,
            1780000,
            1320000,
            516000,
            14000000,
        ],
        "happiness_index": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0],
    }
)

llm = OpenAI()

from llama_index.readers.pandas_ai import PandasAIReader

# use run_pandas_ai directly
# set is_conversational_answer=False to get parsed output
loader = PandasAIReader(llm=llm)
response = reader.run_pandas_ai(
    df, "Which are the 5 happiest countries?", is_conversational_answer=False
)
print(response)

# load data with is_conversational_answer=False
# will use our PandasCSVReader under the hood
docs = reader.load_data(
    df, "Which are the 5 happiest countries?", is_conversational_answer=False
)

# load data with is_conversational_answer=True
# will use our PandasCSVReader under the hood
docs = reader.load_data(
    df, "Which are the 5 happiest countries?", is_conversational_answer=True
)
```

This loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-readers-pandas-ai",
    "maintainer": "jerryjliu",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "ai, pandas",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/75/7c/30d348c001f8bda51436df28ee705d3838e0e0ec7e1821a87ac162b9c193/llama_index_readers_pandas_ai-0.4.1.tar.gz",
    "platform": null,
    "description": "# Pandas AI Loader\n\n```bash\npip install llama-index-readers-pandas-ai\n```\n\nThis loader is a light wrapper around the `PandasAI` Python package.\n\nSee here: https://github.com/gventuri/pandas-ai.\n\nYou can directly get the result of `pandasai.run` command, or\nyou can choose to load in `Document` objects via `load_data`.\n\n## Usage\n\n```python\nfrom pandasai.llm.openai import OpenAI\nimport pandas as pd\n\n# Sample DataFrame\ndf = pd.DataFrame(\n    {\n        \"country\": [\n            \"United States\",\n            \"United Kingdom\",\n            \"France\",\n            \"Germany\",\n            \"Italy\",\n            \"Spain\",\n            \"Canada\",\n            \"Australia\",\n            \"Japan\",\n            \"China\",\n        ],\n        \"gdp\": [\n            21400000,\n            2940000,\n            2830000,\n            3870000,\n            2160000,\n            1350000,\n            1780000,\n            1320000,\n            516000,\n            14000000,\n        ],\n        \"happiness_index\": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0],\n    }\n)\n\nllm = OpenAI()\n\nfrom llama_index.readers.pandas_ai import PandasAIReader\n\n# use run_pandas_ai directly\n# set is_conversational_answer=False to get parsed output\nloader = PandasAIReader(llm=llm)\nresponse = reader.run_pandas_ai(\n    df, \"Which are the 5 happiest countries?\", is_conversational_answer=False\n)\nprint(response)\n\n# load data with is_conversational_answer=False\n# will use our PandasCSVReader under the hood\ndocs = reader.load_data(\n    df, \"Which are the 5 happiest countries?\", is_conversational_answer=False\n)\n\n# load data with is_conversational_answer=True\n# will use our PandasCSVReader under the hood\ndocs = reader.load_data(\n    df, \"Which are the 5 happiest countries?\", is_conversational_answer=True\n)\n```\n\nThis loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index readers pandas_ai integration",
    "version": "0.4.1",
    "project_urls": null,
    "split_keywords": [
        "ai",
        " pandas"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6620e37d58fdc880bc6e62a5a64b83b45f4defb372bc5e3972be74f2dcf2b3c",
                "md5": "ad99a451035db93f8c0d00377d82c2b1",
                "sha256": "497cb2a983f59a27a78cc1ddcc6c12c9a76e14ec5fa4c5663c7a9ca73c9d9d73"
            },
            "downloads": -1,
            "filename": "llama_index_readers_pandas_ai-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ad99a451035db93f8c0d00377d82c2b1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 3592,
            "upload_time": "2024-11-18T16:11:52",
            "upload_time_iso_8601": "2024-11-18T16:11:52.212530Z",
            "url": "https://files.pythonhosted.org/packages/d6/62/0e37d58fdc880bc6e62a5a64b83b45f4defb372bc5e3972be74f2dcf2b3c/llama_index_readers_pandas_ai-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "757c30d348c001f8bda51436df28ee705d3838e0e0ec7e1821a87ac162b9c193",
                "md5": "0e53a1498d9c3b8efea0165bd777d5d4",
                "sha256": "822cef165394fa70572dfd1cbd11701fddcdfc5dc2d27881ba47a734843bc96b"
            },
            "downloads": -1,
            "filename": "llama_index_readers_pandas_ai-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0e53a1498d9c3b8efea0165bd777d5d4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 3328,
            "upload_time": "2024-11-18T16:11:53",
            "upload_time_iso_8601": "2024-11-18T16:11:53.182602Z",
            "url": "https://files.pythonhosted.org/packages/75/7c/30d348c001f8bda51436df28ee705d3838e0e0ec7e1821a87ac162b9c193/llama_index_readers_pandas_ai-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-18 16:11:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-readers-pandas-ai"
}
        
Elapsed time: 0.61519s