forked from Anindyadeep/pandas-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: multiple dataframes (sinaptik-ai#181)
* chore: avoid traversing the code twice for removing df overwrites and unsafe imports * chore: update tests * feat: multiple dataframes supported * chore: update readme * test: generate python code prompt * test: multiple dataframes * test: correct multiple dataframes * docs: add multiple dataframes to the doc * docs: update pai options to include Google Palm --------- Co-authored-by: Gabriele Venturi <[email protected]>
- Loading branch information
1 parent
2c0a6f7
commit be4c717
Showing
9 changed files
with
438 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Example of using PandasAI on multiple Pandas DataFrame""" | ||
|
||
import pandas as pd | ||
from pandasai import PandasAI | ||
from pandasai.llm.openai import OpenAI | ||
|
||
employees_data = { | ||
'EmployeeID': [1, 2, 3, 4, 5], | ||
'Name': ['John', 'Emma', 'Liam', 'Olivia', 'William'], | ||
'Department': ['HR', 'Sales', 'IT', 'Marketing', 'Finance'] | ||
} | ||
|
||
salaries_data = { | ||
'EmployeeID': [1, 2, 3, 4, 5], | ||
'Salary': [5000, 6000, 4500, 7000, 5500] | ||
} | ||
|
||
employees_df = pd.DataFrame(employees_data) | ||
salaries_df = pd.DataFrame(salaries_data) | ||
|
||
|
||
llm = OpenAI() | ||
pandas_ai = PandasAI(llm, verbose=True) | ||
response = pandas_ai([employees_df, salaries_df], "Who gets paid the most?") | ||
print(response) | ||
# Output: Olivia |
Oops, something went wrong.