Skip to main content

llama-index readers pandas_ai integration

Project description

Pandas AI Loader

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 llama_index import download_loader
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()

PandasAIReader = download_loader("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 and/or subsequently used as a Tool in a LangChain Agent. See here for examples.

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.1.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for llama_index_readers_pandas_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bd70fc00ce06a96a6c37458feaf6bbb2d690363917f21ac8bcd503ab26493342
MD5 29eaeda0be99f92e07a0496fb2a169c5
BLAKE2b-256 95b44eb0f658b050f32f24da6033a71bf819e349bcff735917ac72b8ad1bdfa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_readers_pandas_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9bdb00ad2848bcac3377e1a777754fb294cda5493158b3965f4e1f9e5cf1ae5e
MD5 c734a17edeaa5212097c54bf981b0f4d
BLAKE2b-256 2c1614e4c14330f2da1643469278921497dabe9539eb5b7d864e5cd72672285d

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