跳到主要内容
Bodo DataFrames 是一个用于大规模 Python 数据处理的高性能 DataFrame 库,可作为 Pandas 的直接替代品;只需将
import pandas as pd
替换为
import bodo.pandas as pd
即可自动扩展和加速 Pandas 工作负载。由于 Bodo DataFrames 与 Pandas 兼容,它非常适合 LLM 代码生成,易于验证、高效且可扩展,突破了 Pandas 的典型限制。 我们的集成包提供了一个工具包,用于使用 Bodo DataFrames 高效、可扩展地向代理询问大型数据集。 在底层,Bodo DataFrames 使用惰性评估来优化 Pandas 操作序列,通过运算符流式传输数据以处理大于内存的数据集,并利用基于 MPI 的高性能计算技术实现高效并行执行,可轻松从笔记本电脑扩展到大型集群。

安装与设置

pip
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
import bodo.pandas as pd
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'}

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.