> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/stackai-tools/data-and-code/analysis-tool.md).

# Analysis Tool

Analyze files, calculate results, or create a chart from a plain-language question. The tool generates and runs Python code, so you can inspect both the calculation and its result.

## Analyze your data

1. Make the source files available to the workflow or agent. In **Query**, name the relevant files and columns and state the calculation you need.
2. Include filters, units, and how to handle missing values. Each query must contain the information needed for that calculation.
3. Run the tool. Check **Success**, then compare **Result** with the source data. Inspect **Code** when you need to understand the calculation.

**Result:** The result contains the calculation output and executed code. Chart and image links are returned when a chart was created.

## Behavior and troubleshooting

Each execution starts without variables from earlier executions. Include the source and instructions again for a follow-up calculation. If a calculation fails, use the error to clarify the next query. A successful execution does not establish that the chosen calculation or interpretation is correct.

## Inputs

| Field            | Parameter | Description                                                                                    |
| ---------------- | --------- | ---------------------------------------------------------------------------------------------- |
| Query (required) | `query`   | A tool to analyze data, create charts and translate natural language queries into python code. |

## Outputs

| Field     | Parameter   | Description                                              |
| --------- | ----------- | -------------------------------------------------------- |
| Success   | `success`   | Whether the code was executed successfully.              |
| Code      | `code`      | The Python code that was executed.                       |
| Result    | `result`    | The result of the code execution.                        |
| Chart URL | `chart_url` | The public URL of the chart that was generated (if any). |
| Image URL | `image_url` | The public URL of the downloadable chart image (if any). |

## Related guidance

[Data Types, Lists, Missing Values, and Empty Results](https://docs.stackai.com/technical-reference/workflow-execution/data-types-lists-missing-values-and-empty-results.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/stackai-tools/data-and-code/analysis-tool.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
