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
Built Distribution
File details
Details for the file llama_index_readers_pandas_ai-0.1.4.tar.gz
.
File metadata
- Download URL: llama_index_readers_pandas_ai-0.1.4.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 404d655e3a9f051fdc8cc9fdc33ec39d0b40e91fab99803a3cccbfb52df28a29 |
|
MD5 | f87e0cf077ad93d63b556760ac343c4c |
|
BLAKE2b-256 | 299e408c4d9abf05b17ff2e356541930b355811933ed3c55d8bafc91bc4397d4 |
File details
Details for the file llama_index_readers_pandas_ai-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: llama_index_readers_pandas_ai-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62022bcb1adff385455efbae26d816dd035dbb90a3dae8a64000c231f04c33f4 |
|
MD5 | 74275a18981a877195c72169737a98e7 |
|
BLAKE2b-256 | c75a6114bf24c95ff8ffa1c8aecab317e785c4f526475f0a5ac80999526ba8e7 |