Learn how to use PandasAI’s powerful chat functionality and the output formats for natural language data analysis
Release v3 is currently in beta. This documentation reflects the features and functionality in progress and may change before the final release.
The .chat()
method is PandasAI’s core feature that enables natural language interaction with your data. It allows you to:
For a more UI-based data analysis experience, check out our Data Platform.
PandasAI supports multiple output formats for responses, each designed to handle different types of data and analysis results effectively. This document outlines the available output formats and their use cases.
Used when the result is a pandas DataFrame. This format preserves the tabular structure of your data and allows for further data manipulation.
Handles visualization outputs, supporting various types of charts and plots generated during data analysis.
Returns textual responses, explanations, and insights about your data in a readable format.
Specialized format for numerical outputs, typically used for calculations, statistics, and metrics.
Provides structured error information when something goes wrong during the analysis process.
The response format is automatically determined based on the type of analysis performed and the nature of the output. You don’t need to explicitly specify the format - PandasAI will choose the most appropriate one for your results.
Example:
Each response type is designed to handle specific use cases:
The response system is extensible and type-safe, ensuring that outputs are properly formatted and handled according to their specific requirements.
The response object provides several useful methods and properties to interact with the results:
By default, when you print a response object, it automatically returns its .value
property:
You can inspect the code that was generated to produce the result:
For chart responses, you can save the visualization to a file: