Skip to main content
Bodo DataFrames 是一个高性能 DataFrame 库, 用于大规模 Python 数据处理,可直接替代 Pandas;只需将:
import pandas as pd
替换为:
import bodo.pandas as pd
即可自动扩展和加速 Pandas 工作负载。 由于 Bodo DataFrames 与 Pandas 兼容,它是 LLM 代码生成的理想目标, 易于验证、高效且可扩展,超越了 Pandas 的典型限制。 我们的集成包提供了一个工具包,使 Agent 能够使用 Bodo DataFrames 高效且可扩展地回答关于大型数据集的问题。 在底层,Bodo DataFrames 使用惰性求值来优化 Pandas 操作序列, 通过流式传输数据处理超出内存的数据集,并利用基于 MPI 的高性能计算技术实现高效的并行执行, 可以轻松从笔记本电脑扩展到大型集群。

安装与设置

pip
pip install -U langchain_bodo

工具包

langchain-bodo 包提供了创建可使用 Bodo DataFrames 回答大型数据集问题的 Agent 的功能。 有关更详细的使用示例,请参阅 Bodo DataFrames 工具页面 注意:此功能在底层使用 Python Agent,该 Agent 会执行 LLM 生成的 Python 代码——如果 LLM 生成的 Python 代码有害,可能存在风险。请谨慎使用。
from langchain_bodo import create_bodo_dataframes_agent

使用示例

在运行以下代码之前,请复制 titanic 数据集 并在本地保存为 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'}