From aea97efe8bd105a10f127001edfa9fd5d7270915 Mon Sep 17 00:00:00 2001 From: eahova Date: Thu, 20 Jul 2023 09:02:01 -0500 Subject: [PATCH] =?UTF-8?q?Adding=20code=20to=20allow=20pandas=20to=20show?= =?UTF-8?q?=20all=20columns=20instead=20of=20truncating=E2=80=A6=20(#7901)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Description: Adding code to set pandas dataframe to display all the columns. Otherwise, some data get truncated (it puts a "..." in the middle and just shows the first 4 and last 4 columns) and the LLM doesn't realize it isn't getting the full data. Default value is 8, so this helps Dataframes larger than that. - Issue: none - Dependencies: none - Tag maintainer: @hinthornw - Twitter handle: none --- langchain/agents/agent_toolkits/pandas/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/langchain/agents/agent_toolkits/pandas/base.py b/langchain/agents/agent_toolkits/pandas/base.py index fec09514d73..3c8a4615c06 100644 --- a/langchain/agents/agent_toolkits/pandas/base.py +++ b/langchain/agents/agent_toolkits/pandas/base.py @@ -118,6 +118,8 @@ def _get_prompt_and_tools( ) -> Tuple[BasePromptTemplate, List[PythonAstREPLTool]]: try: import pandas as pd + + pd.set_option("display.max_columns", None) except ImportError: raise ValueError( "pandas package not found, please install with `pip install pandas`" @@ -227,6 +229,8 @@ def _get_functions_prompt_and_tools( ) -> Tuple[BasePromptTemplate, List[PythonAstREPLTool]]: try: import pandas as pd + + pd.set_option("display.max_columns", None) except ImportError: raise ValueError( "pandas package not found, please install with `pip install pandas`"