> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Pandas

说明：

使用 agno 库和 PandasTools 实现了一个 AI Agent，用于自动化数据分析。

该 Agent 加载 CSV 文件 (data.csv) 并根据自然语言指令执行分析。

能够在无需手动编写 Pandas 代码的情况下与数据进行交互，简化了数据探索和洞察提取的过程。

包含环境设置和依赖项的安装说明。

***

## title: Pandas 工具

## 代码

```python cookbook/tools/pandas_tools.py theme={null}
from agno.agent import Agent
from agno.tools.pandas import PandasTools

agent = Agent(
    tools=[PandasTools()],
    show_tool_calls=True,
    markdown=True,
)
agent.print_response("Load and analyze the dataset from data.csv")
```

## 用法

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="设置您的 API 密钥">
    ```bash theme={null}
    export OPENAI_API_KEY=xxx
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U pandas openai agno
    ```
  </Step>

  <Step title="运行 Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/tools/pandas_tools.py
      ```

      ```bash Windows theme={null}
      python cookbook/tools/pandas_tools.py
      ```
    </CodeGroup>
  </Step>
</Steps>
