Read and Check AI-Written Code Without Being a Coder
AI-written scripts usually work. "Usually" is the problem. A script can run without any error and still give a wrong answer: a month left out, a total counted twice, a column read as text instead of numbers. Excel would show you the problem on screen. A script will not, unless you check.
This lesson gives you a simple checking routine that does not need programming knowledge. It is the most important lesson in the course.
What You'll Learn
- The handful of pandas words you need to follow most scripts
- How to ask the AI to explain a script line by line
- Four checks that catch most wrong results
- How to spot a column that was read as text
- When to stop and ask a person for help
The words that cover most scripts
You do not need to learn Python. But knowing about ten words lets you follow most Excel scripts. Each one matches something you already do in Excel.
Most Excel scripts are built from these few pieces.
| Criteria | What it does | Like in Excel |
|---|---|---|
| pd.read_excel(...) | Opens an Excel file as a table | File, Open |
| df | A common name for a table (DataFrame) | A sheet of data |
| df['Revenue'] | One column | Column D |
| pd.concat([...]) | Stacks tables on top of each other | Copy and paste below |
| dropna(...) | Removes rows with empty cells | Filter blanks, delete rows |
| df[df['Region'] == 'North'] | Keeps only matching rows | Filter |
| groupby(...).sum() | Totals by group | Pivot table or SUMIF |
| merge(...) | Joins two tables on a shared column | VLOOKUP or XLOOKUP |
| to_excel(...) | Saves the table as an Excel file | Save As |
What it does
- pd.read_excel(...)
- Opens an Excel file as a table
- df
- A common name for a table (DataFrame)
- df['Revenue']
- One column
- pd.concat([...])
- Stacks tables on top of each other
- dropna(...)
- Removes rows with empty cells
- df[df['Region'] == 'North']
- Keeps only matching rows
- groupby(...).sum()
- Totals by group
- merge(...)
- Joins two tables on a shared column
- to_excel(...)
- Saves the table as an Excel file
Like in Excel
- pd.read_excel(...)
- File, Open
- df
- A sheet of data
- df['Revenue']
- Column D
- pd.concat([...])
- Copy and paste below
- dropna(...)
- Filter blanks, delete rows
- df[df['Region'] == 'North']
- Filter
- groupby(...).sum()
- Pivot table or SUMIF
- merge(...)
- VLOOKUP or XLOOKUP
- to_excel(...)
- Save As
For a deeper look at pandas, the Pandas Data Wrangling course covers each one with exercises.
Ask for a line-by-line explanation
Even if the script has comments, ask for a plain explanation before you trust it with real data:
The second part of that prompt is the useful one. Asking "what could go wrong silently?" makes the AI point out its own risky steps.
Four checks that catch most mistakes
Run these checks every time you use a new script on real data. They take five minutes.
Check 1: Row counts
Compare the number of rows going in with the number coming out. If 12 files have about 1,000 rows each, the combined file should have about 12,000, minus any rows you asked to remove.
Ask the script to print the counts, as in lesson 1. If a number looks wrong, something was skipped or duplicated.
Check 2: One total you already know
Pick one number you can check by hand or in Excel, like the total revenue for one month. Compare it with the script's output. If they match, the script is very likely reading the numbers correctly.
Check 3: Look at a few rows
Open the output in Excel and look at the first rows, the last rows and a few in the middle. Are the dates real dates? Are the names spelled the same as before? Is the new column filled in?
Check 4: Test on a small copy first
Before running a script on a big important file, run it on a copy with 10 or 20 rows. Small files make mistakes easy to see.
Spot numbers stored as text
A common silent problem: a column that looks like numbers is actually text, because some cells contain spaces, currency symbols or commas. Totals then come out wrong or fail.
Try it here. The revenue column has a rupee symbol and commas, so pandas reads it as text. Run the code and see what happens to the total, then see the fix.
The last line prints each column's type. object usually means text. int64 or float64 means numbers. If a money or quantity column shows object, ask the AI to convert it.
Now you try
This table has the same problem in the Units column. Turn it into numbers so the total is correct.
When to stop and ask a person
AI help is great for routine jobs. Ask a colleague, teacher or someone who knows Python to look at the script before you rely on it when:
- The output goes to a client, a manager or an official report.
- The script deletes, overwrites or emails anything.
- You still cannot explain what a step does after asking the AI twice.
Key Takeaways
- A script can run without errors and still be wrong, so always check the result.
- About ten pandas words, like read_excel, concat, groupby and merge, cover most Excel scripts.
- Ask the AI to explain the script in Excel terms and to list steps that could fail silently.
- Check row counts, one known total, a few sample rows, and test on a small copy first.
- Watch for numbers stored as text, and get a person to review scripts that matter.
Quiz
Up next · Lesson 4 of 6
Clean Messy Columns and Build a Summary Table
2 min read
3 of 6 lessons done
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

