mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
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:
parent
9306394078
commit
258d67b0ac
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user