以编程方式使用文档

Bodo DataFrames 是一个高性能的 DataFrame 库 用于大规模 Python 数据处理,是 Pandas 的直接替代品;只需替换:

with:

即可自动扩展和加速 Pandas 工作负载。 由于 Bodo DataFrames 与 Pandas 兼容,它是 LLM 代码生成的理想目标 易于验证、高效且可扩展,超越 Pandas 的典型限制。

我们的集成包提供了一个工具包,用于向代理询问有关大型数据集的问题 使用 Bodo DataFrames 以提高效率和可扩展性。

在底层,Bodo DataFrames 使用惰性求值来优化 Pandas 操作序列, 通过运算符流式传输数据以处理大于内存的数据集,并 利用基于 MPI 的高性能计算技术进行高效的并行执行,可以 轻松从笔记本电脑扩展到大型集群。

安装和设置

pip install -U langchain_bodo

工具包

langchain-bodo 包 提供用于创建能够使用 Bodo DataFrames 回答有关大型数据集问题的代理的功能。 请参阅 Bodo DataFrames 工具页面 获取更详细的使用示例。

**注意:此功能在底层使用 Python 代理,它执行 LLM 生成的 Python 代码——如果 LLM 生成的 Python 代码有害,这可能很危险。请谨慎使用。**

from langchain_bodo import create_bodo_dataframes_agent

使用示例

在运行下面的代码之前,请复制 泰坦尼克号数据集 并本地保存为 titanic.csv.

from langchain_openai import OpenAI

df = pd.read_csv("titanic.csv")
agent = create_bodo_dataframes_agent(
    OpenAI(temperature=0), df, verbose=True, allow_dangerous_code=True
)
agent.invoke("how many rows are there?")
> Entering new AgentExecutor chain...
Thought: I can use the len() function to get the number of rows in the dataframe.
Action: python_repl_ast
Action Input: len(df)891891 is the number of rows in the dataframe.
Final Answer: 891

> Finished chain.
{'input': 'how many rows are there?', 'output': '891'}