Code Mode

Code Mode provides a Python-first environment for data analysis, visualization, and file manipulation.

Overview

When you select Code Mode, you’re working with the Data Agent—an AI assistant specialized in:

  • Writing and executing Python code
  • Analyzing data files in your workspace
  • Creating visualizations
  • Building data pipelines
  • Generating downloadable artifacts

Getting Started

Switching to Code Mode

  1. Open Deep Data Agent from the Hub
  2. Look for the mode selector at the top of the chat
  3. Click Code to enable Code Mode

Your First Analysis

Try a simple prompt:

Load the sales.csv file and show me a summary of the data

The agent will:

  1. Write Python code to load your file
  2. Execute it in a secure sandbox
  3. Display the results inline
  4. Show you the code it used

Working with Files

Uploading Files

Drag and drop files directly into the chat, or use the upload button. Supported formats:

  • Tabular: CSV, Excel (.xlsx, .xls), Parquet, JSON
  • Text: TXT, Markdown, PDF
  • Code: Python, JavaScript, SQL

Referencing Files

Reference files by name in your prompts:

Analyze the customer_data.csv file
Compare sales_2023.xlsx with sales_2024.xlsx
Read the README.md and summarize it

File Operations

The agent can create, modify, and export files:

Clean the data and save it as cleaned_data.parquet
Export the results to an Excel file
Create a Python script that automates this analysis

Data Analysis

Exploratory Analysis

Show me the shape, columns, and data types of orders.csv
What are the summary statistics for all numeric columns?
Are there any missing values? Show me a breakdown by column

Filtering and Querying

Show me all orders over $1000 from California
Group sales by region and calculate the average
Find the top 10 customers by total purchase amount

Transformations

Create a new column for profit margin (revenue - cost) / revenue
Convert the date column to datetime and extract month
Normalize the price column to a 0-1 scale

Visualizations

Basic Charts

Create a bar chart of sales by region
Show me a line chart of monthly revenue trends
Make a scatter plot of price vs quantity

Advanced Visualizations

Create a heatmap showing correlation between numeric columns
Build a dashboard with sales by region, monthly trends, and top products
Show me a box plot of order values grouped by customer segment

Customization

Make the chart larger with a dark background
Add a title and axis labels
Use the Calliope brand colors (provide hex codes)

Code Execution

Viewing Generated Code

Every response includes the Python code used. Click “Show Code” to see it.

Modifying Code

Ask the agent to adjust its approach:

Use pandas instead of polars for this analysis
Add error handling for missing files
Make the code more efficient for large datasets

Running Custom Code

You can provide your own code:

Run this code:

import pandas as pd
df = pd.read_csv('data.csv')
print(df.describe())

Available Libraries

Code Mode has common data science libraries pre-installed:

CategoryLibraries
Datapandas, polars, numpy
Visualizationmatplotlib, seaborn, plotly
Machine Learningscikit-learn, xgboost
Statisticsscipy, statsmodels
Utilitiesrequests, beautifulsoup4

Need a library that’s not available? Let us know.

Artifacts and Downloads

Creating Downloadable Files

Save the cleaned data as a CSV I can download
Export the chart as a PNG
Create a PDF report with the analysis

Accessing Downloads

Generated files appear as download links in the chat. Click to download directly.

Best Practices

Be Specific

Instead of: “Analyze this data”

Try: “Calculate the monthly growth rate and identify which products are declining”

Iterate

Start broad, then refine:

  1. “Show me a summary of the data”
  2. “Focus on the revenue column”
  3. “Break it down by region”
  4. “Show just Q4 2024”

Use Context

Reference previous results:

Using that filtered data, create a visualization
Apply the same transformation to the other file

Request Formats

Be explicit about output format:

Show this as a table
Give me a chart, not a table
Export as Excel with multiple sheets

Troubleshooting

“File not found”

  • Check the exact filename (case-sensitive)
  • Make sure the file was uploaded successfully
  • Try listing files: “What files are in my workspace?”

Slow responses

  • Large files take longer to process
  • Complex visualizations need more time
  • Try working with a sample first: “Analyze the first 1000 rows”

Unexpected results

  • Ask to see the code: “Show me the code you used”
  • Check data types: “What are the column types?”
  • Verify the data: “Show me the first 10 rows”