examples/quickstart.ipynb
This notebook demonstrates how to get started with PandasAI and how to use it to analyze data through natural language.
Use pandasai_litellm to select the LLm of your choice and use PandasAI
import pandasai as pai
from pandasai_litellm.litellm import LiteLLM
# Initialize LiteLLM with your OpenAI model
llm = LiteLLM(model="gpt-4.1-mini", api_key="YOUR_OPENAI_API_KEY")
# Configure PandasAI to use this LLM
pai.config.set({
"llm": llm
})
For this example, we will use a small dataset of heart disease patients from Kaggle.
file_df = pai.read_csv("./data/heart.csv")
You can ask questions about your data using natural language
response = file_df.chat("What is the correlation between age and cholesterol?")
print(response)
To avoid to reading the csv again and again create dataset in PandasAI to reused. The path must be in format 'organization/dataset'.
dataset = pai.create(path="your-organization/heart",
name="Heart",
df = file_df,
description="Heart Disease Dataset")
After creation you load dataset anytime with the following code
dataset = pai.load("your-organization/heart")