Comments (1)
Hey there, @ReeveWu! I'm here to help you with any bugs, questions, or contributions you have. Let's squash those bugs together! 🤖
The issue you're encountering is due to the Agent
class in pandasai
not handling unhashable types like lists in DataFrame columns. The error message "unhashable type: 'list'" indicates that the Agent
class is trying to process the list data type in a way that requires hashing, which is not possible for lists.
To work around this issue, you can preprocess the DataFrame to convert the list columns into a format that can be handled by the Agent
class. One common approach is to convert the lists into strings or another hashable type.
Here's an example of how you can modify your DataFrame before passing it to the Agent
:
import pandas as pd
import os
from pandasai import Agent, Config
from pandasai.llm import OpenAI
data = {
'Employee_ID': [101, 102, 103, 104],
'Employee_Name': ['Alice', 'Bob', 'Charlie', 'Diana'],
'Projects': [['Project A', 'Project B'], ['Project C'], ['Project D', 'Project E', 'Project F'], ['Project G']],
'Salary': [70000, 80000, 75000, 90000]
}
df = pd.DataFrame(data)
# Convert list columns to strings
df['Projects'] = df['Projects'].apply(lambda x: ', '.join(x))
agent = Agent(
dfs=df,
config=Config(llm=OpenAI(api_token=os.getenv("OAI_API_KEY"), model="gpt-4o"))
)
print(agent.chat('Tell me the average salary of the employees'))
This code converts the Projects
column from lists to comma-separated strings, which should be hashable and thus avoid the "unhashable type: 'list'" error.
If you need to perform more complex analysis on the list data, you might need to implement additional preprocessing steps or custom handling within your analysis logic.
To continue talking to Dosu, mention @dosu.
from pandas-ai.
Related Issues (20)
- Issue in output table conflict with index and column data HOT 2
- how to train using GooglePalm - MissingVectorStoreError: No vector store provided. Please provide a vector store to train the agent. HOT 6
- how to deal with multiple dataframes HOT 2
- Ollama models are not working with Loca;LLM HOT 1
- No results with local llama models HOT 1
- Using local model with PandasAI results in error HOT 1
- Feature generation HOT 1
- use openai error(openai.BadRequestError: Error code: 400) HOT 4
- SemanticAgent can trigger RCE through conversation HOT 2
- Problem with installing with docker on macos HOT 9
- Error when installing with docker HOT 20
- How to use PandasAI agent with local LLM HOT 5
- Make openai as optional dependency
- ERROR [server 8/12] RUN poetry install --no-root / docker compose build / ubuntu 22 HOT 2
- ERROR [client internal] load metadata for docker.io/library/node:19.4 HOT 17
- Sensitive data leakage HOT 2
- Data sharing on log publish HOT 3
- Issue on docs HOT 1
- Passing and receiving response headers to and from the language model
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandas-ai.