Replies: 2 comments
-
To connect pandasAI Agents with connectors and add the field description of a dataset while using the properties of agents, you can follow the example below. The import pandas as pd
from pandasai import Agent
from pandasai.connectors import PandasConnector
# Example DataFrame
data = {
'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 35],
'City': ['New York', 'Los Angeles', 'Chicago']
}
df = pd.DataFrame(data)
# Create a PandasConnector
connector = PandasConnector({"original_df": df})
# Description of the dataset
description = "This dataset contains information about individuals including their name, age, and city."
# Initialize the Agent with the connector and description
agent = Agent(dfs=connector, description=description)
# Now you can use the agent's properties and methods
print(agent.description) # Output: This dataset contains information about individuals including their name, age, and city. In this example:
Additionally, if you are using a different connector like import os
from pandasai import Agent
from pandasai.ee.connectors import DatabricksConnector
databricks_connector = DatabricksConnector(
config={
"host": "adb-*****.azuredatabricks.net",
"database": "default",
"token": "dapidfd412321",
"port": 443,
"table": "loan_payments_data",
"httpPath": "/sql/1.0/warehouses/213421312",
"where": [
["loan_status", "=", "PAIDOFF"],
],
}
)
os.environ["PANDASAI_API_KEY"] = "your-api-key"
# Description of the dataset
description = "This dataset contains loan payment information including loan status and payment details."
agent = Agent(databricks_connector, description=description)
response = agent.chat("How many people from the United States?")
print(response) In this example: |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks. Got resolved |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to know if it is possible to connect pandasAI Agents with connectors. If yes how to do it.
I would like to add the field description of dataset using connectors and also use the properties of agents. The docs only show the integration with smartdataframe/lake
Beta Was this translation helpful? Give feedback.
All reactions