By Diogenes Monegro · · 7 min read
Reading Excel in Python with pandas: The Most Common Errors and How to Fix Them
A free Google Colab notebook to learn pandas from scratch with a real Excel file: 19 typical errors when reading Excel in Python, with their cause and fix, plus a scored lab to practice.
Almost every business keeps its information in Excel: sales exported from the point of sale, inventory, bank statements, customer lists. When that work repeats every week, Python with the pandas library does it in seconds, with no copy-and-paste mistakes.
The problem is the first attempt. You write pd.read_excel("sales.xlsx") and get columns called Unnamed: 1, swapped dates, codes without their leading zeros and a KeyError that makes no sense. It's not your fault: Excel files are made for people to read, not programs.
That's why we built a free, hands-on notebook. You open it in Google Colab, run it without installing anything, and learn pandas by solving the problems you will actually run into.
Open the notebook in Google Colab
👉 Open the notebook in Google Colab
Google Colab is a hosted Jupyter notebook service that requires no setup and is free to use. All you need is a Google account. pandas and openpyxl, the library pandas uses to read .xlsx files, come preinstalled.
To use it:
- Open the link above.
- Go to File → Save a copy in Drive. That way your changes and your lab answers are saved to your account.
- Run the cells in order with Shift + Enter.
The notebook builds its own practice Excel file, so there is nothing to download. If you'd rather work on your own computer, you can also download the notebook from GitHub.
What you will learn
The notebook is written for someone who has never used pandas. It has five parts:
- pandas in 10 minutes: what a
Seriesand aDataFrameare, and how to select, filter, sort and group data. - How to read Excel with
pd.read_excel: the parameters you'll use most (sheet_name,header,usecols,dtype,nrows). - 19 notes on the most common errors, each with the symptom, the cause, the fix and code that reproduces the problem.
- A final recipe: one function that applies every fix and reads the monthly report in a single line.
- A scored lab: 8 challenges and 4 questions that check themselves and add up to 100 points.
The example is the sales report of a hardware store with three branches. It has the usual problems on purpose: a title above the table, merged cells, a totals row with a formula, dates stored as text, prices written as "$ 1,250.00" and branch names typed several different ways.
The most common errors when reading Excel in Python
These are the ones we see most in real projects. The notebook covers all 19, with code you can run.
Unnamed: 0, Unnamed: 1 columns
pandas assumes the column names are on the first row. If the report has a title on top, that title becomes the header. The fix is to tell it which row holds the real header, counting from zero:
df = pd.read_excel("sales.xlsx", sheet_name="Sales", header=3)
If you don't know which row it is, read the first rows without a header (header=None, nrows=10) and look at them.
KeyError on a column that does exist
In Excel the column says "Date", but its real name is " Date", with a leading space. Normalize every name as soon as you read the file:
df.columns = df.columns.str.strip().str.lower().str.replace(" ", "_")
Swapped dates
Files from international suppliers, or from systems set up outside the US, often store dates as day/month text ("05/11/2026"). pandas assumes US order, month first. November 5 becomes May 11, and if no day is above 12 you won't get any error. Always state the format:
df["date"] = pd.to_datetime(df["date"], format="%d/%m/%Y")
The opposite also happens: you see a number like 46356 where a date should be. Excel stores dates as the number of days elapsed since 1900, and sometimes that number is what reaches pandas. The notebook shows how to convert it.
Codes that lose their leading zeros
Excel shows 00101, but the cell stores the number 101 with a five-digit format. pandas reads the number, not the format. It happens with product codes, ZIP codes, employee IDs and phone numbers. Turn it into text and pad it with zeros:
df["code"] = df["code"].astype("Int64").astype(str).str.zfill(5)
Careful: dtype=str only keeps the zeros when the cell was already text in Excel, or when you read a CSV.
Formulas that come back empty
pandas doesn't calculate formulas: it reads the last value Excel saved in the file. If another system generated the file and it was never opened in Excel, that value doesn't exist and you get NaN. The safest option is to recompute the total in pandas instead of trusting the totals row.
Numbers stored as text
When a column mixes 1250 with "$ 1,250.00", summing it raises a TypeError. Strip the symbol and the commas, convert with pd.to_numeric(..., errors="coerce"), and check which values couldn't be converted before moving on.
The same value typed several ways
"Northside" and "Northside " are two different groups to pandas. Before grouping, clean the text with .str.strip().str.title().
to_excel wiped my other sheets
df.to_excel("file.xlsx") creates the file from scratch. To write several sheets use pd.ExcelWriter, and to add a sheet to an existing file use mode="a" with if_sheet_exists="replace".
An .xls that isn't Excel
Many banks and business systems export .xls files that are really a web page or a CSV. Excel opens them without complaint, but pandas answers with Excel file format cannot be determined. The notebook includes a five-line function that looks at the file's first bytes and tells you what it really is.
The lab: learn by playing
At the end of the notebook it's your turn. Each challenge has a space for your code and a line that checks it when you run the cell: you get ✅ or ❌ with a hint. Some of the challenges:
- Read the inventory sheet, whose header is on row 3.
- Bring back the leading zeros in the codes and turn the costs into numbers.
- Join sales with inventory and find which branch earns the most margin.
- Find the salesperson with the most sales in the second half of the month.
- Deliver the result in an Excel file with two sheets.
The prediction questions ask you to guess what will happen before you run the code, which is the best way to make what you learned stick. When you finish, scoreboard() gives you your score. The solutions are hidden at the end in case you get stuck.
There is also an experiments area for breaking things on purpose, and a cell to upload your own Excel file in Colab and start cleaning it.
From an exercise to an automated report
The notebook's recipe ends in a function, read_clean_sales(), that applies every fix in order. That's the idea that saves the most time: once you know which fixes a file needs, you write them once and next month's report comes out with one line of code.
If your team still builds reports by copying and pasting between sheets, it's also worth reading how to build an Excel dashboard that updates automatically and how to get started with business intelligence in a small business. And if you want to go further with Python, we have a guide on Python for AI and how to build your first agent.
Sources
- pandas.read_excel(opens in a new tab) — pandas (NumFOCUS), 2026
- Date systems in Excel(opens in a new tab) — Microsoft Support, 2026
- Colaboratory: Frequently Asked Questions(opens in a new tab) — Google Research, 2026
About the author
Diogenes MonegroCEO, ShineTechData
Diogenes Monegro is the CEO of ShineTechData, a data and AI consultancy based in San Pedro de Macorís, Dominican Republic, that helps small and mid-sized businesses put their data to work.