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
pull/11147/head
Harrison Chase 11 months ago committed by GitHub
parent 9306394078
commit 258d67b0ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save