-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
load and examples scripts #1472
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
import pandasai as pai | ||
|
||
os.environ["PANDASAI_API_URL"] = "http://localhost:8000/" | ||
os.environ["PANDASAI_API_KEY"] = "PAI-test-key" | ||
|
||
# Load using organization/dataset format | ||
#df = pai.load("/home/giuseppe/Projects/pandas-ai/datasets/testing/loans") | ||
df = pai.load("/home/giuseppe/Projects/pandas-ai/datasets/testing/loans", virtualized=True) | ||
|
||
print(df.head()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import pandasai as pai | ||
|
||
os.environ["PANDASAI_API_URL"] = "http://localhost:8000/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gdcsinaptik I'd remove this as it's not meant to be committed. The default value should be used by default |
||
os.environ["PANDASAI_API_KEY"] = "PAI-test-key" | ||
|
||
df = pai.read_csv("/home/giuseppe/Projects/pandas-ai/examples/data/Loan payments data.csv") | ||
|
||
# ask questions | ||
# replace "Which are the top 5 countries by sales?" with your question | ||
response =df.chat('How many loans are from men and have been paid off?') | ||
print(response) | ||
|
||
img =df.chat('Plot the chart of loans paid off by men vs by women') | ||
print(img) | ||
|
||
""" | ||
#minimal save | ||
df.save( | ||
path="testing/loans", | ||
name="loans", | ||
description="Loans dataset" | ||
) | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
import pandasai as pai | ||
|
||
os.environ["PANDASAI_API_URL"] = "http://localhost:8000/" | ||
os.environ["PANDASAI_API_KEY"] = "PAI-test-key" | ||
|
||
df = pai.read_csv("/home/giuseppe/Projects/pandas-ai/examples/data/Loan payments data.csv") | ||
|
||
#save with fields descriptions | ||
df.save( | ||
path="testing/loans", | ||
name="loans", | ||
description="Loans dataset", | ||
columns=[ | ||
{ | ||
"name": "Loan_ID", | ||
"type": "string", | ||
"description": "Unique identifier for each loan" | ||
}, | ||
{ | ||
"name": "loan_status", | ||
"type": "string", | ||
"description": "Status of the loan (PAIDOFF, COLLECTION, COLLECTION_PAIDOFF)" | ||
}, | ||
{ | ||
"name": "Principal", | ||
"type": "number", | ||
"description": "The initial amount of the loan" | ||
}, | ||
{ | ||
"name": "terms", | ||
"type": "number", | ||
"description": "The duration of the loan in days" | ||
}, | ||
{ | ||
"name": "effective_date", | ||
"type": "date", | ||
"description": "The date when the loan became effective" | ||
}, | ||
{ | ||
"name": "due_date", | ||
"type": "date", | ||
"description": "The date when the loan payment is due" | ||
}, | ||
{ | ||
"name": "paid_off_time", | ||
"type": "datetime", | ||
"description": "The timestamp when the loan was paid off (if applicable)" | ||
}, | ||
{ | ||
"name": "past_due_days", | ||
"type": "number", | ||
"description": "Number of days the payment is past due (if applicable)" | ||
}, | ||
{ | ||
"name": "age", | ||
"type": "number", | ||
"description": "Age of the borrower" | ||
}, | ||
{ | ||
"name": "education", | ||
"type": "string", | ||
"description": "Education level of the borrower (High School or Below, Bachelor, college, Master or Above)" | ||
}, | ||
{ | ||
"name": "Gender", | ||
"type": "string", | ||
"description": "Gender of the borrower (male/female)" | ||
} | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
import pandasai as pai | ||
from pandasai_openai import OpenAI | ||
|
||
os.environ["PANDASAI_API_URL"] = "http://localhost:8000/" | ||
os.environ["PANDASAI_API_KEY"] = "PAI-test-key" | ||
|
||
llm = OpenAI(api_token="your-key") | ||
# Print LLM details | ||
print("LLM Type:", type(llm).__name__) | ||
print("LLM Instance:", llm) | ||
print("LLM Model:", llm.model) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gdcsinaptik why are we printing these? |
||
|
||
pai.config.set({ | ||
"llm": llm, | ||
}) | ||
|
||
# Print current config to verify LLM setting | ||
print("\nCurrent PandasAI Config:") | ||
print("Active LLM:", pai.config._config.llm) | ||
|
||
df = pai.load("/home/giuseppe/Projects/pandas-ai/datasets/testing/loans") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gdcsinaptik this is wrong |
||
print(df.head()) | ||
|
||
response = df.chat("What is the average age of the borrowers?") | ||
|
||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gdcsinaptik I'd remove this as it's not meant to be committed. The default value should be used by default