create_pandas_dataframe_agent to load all rows #18659
Replies: 3 comments 4 replies
-
Hey there, @Raghulkannan14! Great to see you diving into another issue. How have you been since our last interaction? Based on the information you've provided, it seems like you're trying to load all rows from a dataframe using the This behavior is due to the To load all rows from your dataframe, you need to set from langchain_openai import ChatOpenAI
from langchain_experimental.agents import create_pandas_dataframe_agent
import pandas as pd
df = pd.read_csv("your_data.csv")
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
agent_executor = create_pandas_dataframe_agent(
llm,
df,
agent_type="openai-tools",
verbose=True,
number_of_head_rows=df.shape[0] # Set this to the total number of rows in df
) This modification should ensure that the entire dataframe is considered when the agent is generating responses, rather than just the first 5 rows. For more information, you can refer to the LangChain repository where the I hope this helps! If you have any other questions or need further clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
-
The only solution i got is using in number_of_head_rows=max_rows_df_arrys, but that increase the number of promt tokens |
Beta Was this translation helpful? Give feedback.
-
It's because it injects the first 5 rows into the prompt and sometimes the LLM will assume that's all the data. I've had success with adding this to my prompt:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
How to load all the rows to the agent for getting answer, It only uses first 5rows to anwer.
System Info
Error
Beta Was this translation helpful? Give feedback.
All reactions