Revert "improve the performance of base.py" (#11143)

Reverts langchain-ai/langchain#8610

this is actually an oversight - this merges all dfs into one df. we DO
NOT want to do this - the idea is we work and manipulate multiple dfs
This commit is contained in:
Harrison Chase 2023-09-27 17:37:29 -07:00 committed by GitHub
parent 9306394078
commit 258d67b0ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,13 +24,11 @@ def create_csv_agent(
if isinstance(path, (str, IOBase)): if isinstance(path, (str, IOBase)):
df = pd.read_csv(path, **_kwargs) df = pd.read_csv(path, **_kwargs)
elif isinstance(path, list): elif isinstance(path, list):
if not all(isinstance(item, (str, IOBase)) for item in path): df = []
raise ValueError( for item in path:
f"Expected all elements in the list to be strings, got {type(path)}." if not isinstance(item, (str, IOBase)):
) raise ValueError(f"Expected str or file-like object, got {type(path)}")
dfs = [pd.read_csv(item, **_kwargs) for item in path] df.append(pd.read_csv(item, **_kwargs))
df = pd.concat(dfs, ignore_index=True)
else: else:
raise ValueError(f"Expected str or list, got {type(path)}") raise ValueError(f"Expected str, list, or file-like object, got {type(path)}")
return create_pandas_dataframe_agent(llm, df, **kwargs) return create_pandas_dataframe_agent(llm, df, **kwargs)