Skip to main content

llama-index readers pandas_ai integration

Project description

Pandas AI Loader

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_readers_pandas_ai-0.4.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file llama_index_readers_pandas_ai-0.4.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_readers_pandas_ai-0.4.1.tar.gz
Algorithm Hash digest
SHA256 822cef165394fa70572dfd1cbd11701fddcdfc5dc2d27881ba47a734843bc96b
MD5 0e53a1498d9c3b8efea0165bd777d5d4
BLAKE2b-256 757c30d348c001f8bda51436df28ee705d3838e0e0ec7e1821a87ac162b9c193

See more details on using hashes here.

File details

Details for the file llama_index_readers_pandas_ai-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_readers_pandas_ai-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 497cb2a983f59a27a78cc1ddcc6c12c9a76e14ec5fa4c5663c7a9ca73c9d9d73
MD5 ad99a451035db93f8c0d00377d82c2b1
BLAKE2b-256 d6620e37d58fdc880bc6e62a5a64b83b45f4defb372bc5e3972be74f2dcf2b3c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page