Chat and output formats
Learn how to use PandaAI’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.
Chat
The .chat()
method is PandaAI’s core feature that enables natural language interaction with your data. It allows you to:
- Query your data using plain English
- Generate visualizations and statistical analyses
- Work with multiple DataFrames simultaneously
For a more UI-based data analysis experience, check out our Data Platform.
Basic Usage
Chat with multiple DataFrames
Available Output Formats
PandaAI 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.
DataFrame Response
Used when the result is a pandas DataFrame. This format preserves the tabular structure of your data and allows for further data manipulation.
Chart Response
Handles visualization outputs, supporting various types of charts and plots generated during data analysis.
String Response
Returns textual responses, explanations, and insights about your data in a readable format.
Number Response
Specialized format for numerical outputs, typically used for calculations, statistics, and metrics.
Error Response
Provides structured error information when something goes wrong during the analysis process.
Usage
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 - PandaAI will choose the most appropriate one for your results.
Example:
Response Types Details
Each response type is designed to handle specific use cases:
- String Response: Provides textual analysis and explanations
- Number Response: Returns numerical results from calculations
- DataFrame Response: Preserves the structure and functionality of pandas DataFrames
- Chart Response: Handles various visualization formats and plotting libraries
- Error Response: Structured error handling with informative messages
The response system is extensible and type-safe, ensuring that outputs are properly formatted and handled according to their specific requirements.
Response Object Methods
The response object provides several useful methods and properties to interact with the results:
Value Property
By default, when you print a response object, it automatically returns its .value
property:
Generated Code
You can inspect the code that was generated to produce the result:
Saving Charts
For chart responses, you can save the visualization to a file:
Was this page helpful?