A workflow demonstrating how the Data Analyst Agent can read data from various sources, analyze it, and generate insights.

Quick Start

1

Install Package

First, install the PraisonAI Agents package:

pip install praisonaiagents
2

Set API Key

Set your OpenAI API key as an environment variable:

export OPENAI_API_KEY=your_api_key_here
3

Create Script

Create a new file data_analysis.py:

from praisonaiagents import Agent, Tools
from praisonaiagents.tools import (
    read_csv, read_excel, write_csv, write_excel,
    filter_data, get_summary, group_by, pivot_table
)

agent = Agent(
    instructions="You are a Data Analyst Agent",
    tools=[
        read_csv, read_excel, write_csv, write_excel,
        filter_data, get_summary, group_by, pivot_table
    ]
)

# Start analysis with a specific task
agent.start(f"""
    Read the data from the csv file {os.path.join(os.path.dirname(__file__), "tesla-stock-price.csv")}
    Analyse the data and give me the insights
    read_csv to read the file
""")

Understanding Data Analysis Workflow

The Data Analyst Agent is designed to perform comprehensive data analysis tasks using a suite of specialized tools. Here’s how it works:

  1. Data Reading: The agent can read data from various sources:

    • CSV files using read_csv
    • Excel files using read_excel
  2. Data Analysis: Multiple analysis tools are available:

    • filter_data: Filter datasets based on conditions
    • get_summary: Generate statistical summaries
    • group_by: Group data by specific columns
    • pivot_table: Create pivot tables for analysis
  3. Data Export: Results can be exported to:

    • CSV format using write_csv
    • Excel format using write_excel

Features

Multiple Data Sources

Support for both CSV and Excel file formats.

Analysis Tools

Comprehensive suite of analysis tools including filtering, summarization, and pivoting.

Data Export

Export capabilities to various formats.

Automated Insights

Automatic generation of data insights and patterns.

Example Usage

# Example: Analyzing stock data
agent.start("""
    1. Read 'stock_data.csv'
    2. Filter data for the last 30 days
    3. Calculate daily returns
    4. Generate summary statistics
    5. Export results to 'analysis_results.xlsx'
""")

Next Steps

Was this page helpful?