Skip to content

Lesson 11 ยท Files, Data and Code

Data Analysis and Charts in ChatGPT

Analyze spreadsheets in ChatGPT with its Python tool, ask for clean data and charts, inspect the code it ran, and verify totals and assumptions.

Upload a spreadsheet and ask "which month had the highest sales?", and ChatGPT can often answer by writing and running Python code. OpenAI's help page describes a notebook-style environment that can use your uploaded files and show tables. Code is far more reliable for arithmetic than a model estimating numbers, but the code can still rest on a wrong assumption.

What it can help with

  • Describe a dataset: columns, types and missing values.
  • Find duplicates, odd values and inconsistent categories.
  • Calculate totals, averages, counts and spreads.
  • Group, filter and sort.
  • Make charts. As of December 2026, OpenAI says interactive charts are supported for bar, line, pie and scatter charts; other types are usually static images.

The same help page says this code environment cannot make web requests or API calls. If you need outside data, upload it or connect a supported source first.

A safe analysis workflow

  1. Describe first. "Show the columns, data types, row count and missing values. Do not analyze yet."
  2. Agree on definitions. What counts as a sale? Are refunds negative numbers?
  3. Clean with a record. "List every change you make and how many rows it affects."
  4. Analyze. Ask one question at a time.
  5. Verify. Check totals against something you trust.

Prompts that help

TEXT
Before any analysis, tell me:
- number of rows and columns
- missing values per column
- duplicate rows
- any dates that failed to parse
Then wait.
TEXT
Make a bar chart of monthly revenue. Exclude test orders (customer
name starts with "TEST"). Show the code you ran and the table behind
the chart.

Asking for the code and the table gives you two things to check. If you read some Python or SQL, review the filters. If you do not, ask for a plain-language list of each step.

Reproduce a total yourself

Small checks catch big mistakes. This runnable block uses only Python's standard library on a tiny invented sales table. Notice the traps: a duplicate row, a test order and a missing value.

Python Clean and total a small sales table

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The naive total is far from the cleaned total. Someone has to decide whether the missing amount should be investigated or excluded. That is a business decision, not a math one.

Check the result

  • Row counts before and after each cleaning step.
  • Control totals: compare with a number from your source system.
  • Spot checks: pick five rows and trace them by hand.
  • Chart axes: labels, units, start of the scale and time order.
  • Method: was it a mean or a median? Which rows were excluded? The tool may choose a method you did not expect.

Interpreting patterns

Two things moving together does not show that one causes the other. If ChatGPT writes "the campaign increased sales", ask what else changed, what the comparison group was and how much data there is. A small sample can easily produce a pattern by chance.

TEXT
List alternative explanations for this trend and what data would help
tell them apart. Do not claim a cause unless the data can support it.

Export your work

Ask for cleaned data as a downloadable file, along with a short "data notes" section explaining the rules. Keep the original file unchanged, so you can redo the work.

Protect data

Customer and employee data often have legal protections. Remove names and identifiers, or replace them with codes, unless your organization has approved this use. Sometimes the safest option is to ask ChatGPT for a formula or script using made-up sample data, and then run it on the real data yourself.

An example conversation

A productive analysis often looks like a short interview. You upload the file and ask for a description. ChatGPT reports the columns and problems. You answer its open questions, such as whether empty amounts mean zero or unknown. You then ask one analysis question and review the table before asking for a chart. Each step is small enough to check, and a wrong assumption shows up early.

If a result surprises you, do not accept it or reject it at once. Ask which rows contribute most to the result:

TEXT
Show the five rows that contribute most to the February total.
Then show how the total changes without the largest one.

A single unusual row can drive a whole conclusion, and this prompt exposes it.

Choose the right summary

The mean adds values and divides by how many there are, so one very large value pulls it upward. The median is the middle value and is less affected by extremes. For response times, prices or incomes, report both, or explain your choice. Also say how many rows each number is based on. An average of three records deserves far less confidence than an average of three thousand.

Know when to use another tool

For a monthly report that others depend on, a spreadsheet or script that you control may be better than a new chat each time. You can ask ChatGPT to help write it, test it on sample data and then run it yourself. The steps become visible, repeatable and easy to review.

Practice with known answers

Make a ten-row table where you already know the totals, then include one duplicate and one blank cell. Ask for the analysis and see whether both problems are reported. Testing with known answers is the quickest way to learn which instructions you need to spell out, such as how to treat blanks.

Common mistake: reporting a chart without checking which rows were filtered out. Ask for the filters and counts every time.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. Why ask ChatGPT to describe the dataset before analyzing it?

    Looking first lets you set cleaning rules deliberately.
  2. 2. What can the data analysis code environment not do, according to OpenAI's help page?

    Upload or connect the data you need before analysis.
  3. 3. Sales rose after a new ad. What is the right conclusion from that fact alone?

    Timing alone does not show cause.

Summary

  • ChatGPT can run Python on your files to calculate and chart.
  • Describe, define, clean, analyze, then verify.
  • Check row counts, control totals and spot samples.
  • Do not read causes into patterns without evidence.
  • Protect personal and company data.

Next: Coding With ChatGPT: Explain, Write and Debug

Your progress is saved in this browser. No account needed.