What Most People Miss About How Python Help With Excel

A 2023 workplace survey of 1,247 finance and ops professionals found that 58% run Excel reports weekly — but only 9% use any automation beyond basic formulas. The rest? Copy-paste, manual filtering, and reformatting every time.

The Setup

You get a raw export from your ERP system: Orders_2024_Q1.xlsx, saved in C:\Reports\Raw\. It’s got 927 rows, inconsistent date formats, mixed currency symbols, and three columns you actually need: Order_ID, Customer_Name, and Total_Amount.

Here’s a realistic slice (rows 1–9 of the raw sheet, A1:C9):

Order_ID Customer_Name Total_Amount
ORD-7821 Sarah Chen $2,450.00
ORD-7822 Acme Corp USD 1,890
ORD-7823 J. M. Rodriguez 2,130.50
ORD-7824 Nexus Labs Inc. $1,670.25
ORD-7825 T. L. Kim USD 3,012
ORD-7826 Vista Dynamics 2,745.99
ORD-7827 Luna Systems $1,900.00
ORD-7828 Baxter & Sons USD 2,280

The Challenge

You need this cleaned and ready for your monthly dashboard by 10 a.m. — but doing it manually means:

  • Fixing 12 different currency formats across 927 rows
  • Converting dates like 03/15/2024, 15-Mar-2024, and 20240315 into Excel-recognized serials
  • Adding a Fiscal_Quarter column (Q1 = Jan–Mar)
  • Filtering out orders under $1,500
  • Exporting only Order_ID, Customer_Name, Total_Amount, and Fiscal_Quarter to Dashboard_Ready.xlsx

And yes — you could do all this in Power Query. But if you’ve ever opened Power Query Editor and stared at the formula bar wondering what Table.TransformColumns really does… you’re not alone. (Trust me, I learned this the hard way.)

Walking Through It

We’ll use pandas and openpyxl — two free, well-documented libraries. No VBA. No COM objects. Just Python 3.9+ and 6 lines of code.

Step 1: Load and inspect
Run this in Jupyter or VS Code:

import pandas as pd
raw = pd.read_excel(r"C:\Reports\Raw\Orders_2024_Q1.xlsx", usecols="A:C")
print(raw.head(5))

You’ll see the messy amounts — some with $, some with USD, some bare numbers. That’s fine. Pandas doesn’t care about formatting — it sees the underlying string.

Step 2: Clean the amount column
This is where most people overcomplicate things. You don’t need regex. Try this instead:

raw['Total_Amount'] = raw['Total_Amount'].astype(str).str.replace(r'[^\d.]', '', regex=True).astype(float)

It strips everything except digits and periods — then converts to float. Works on $2,450.00, USD 1,890, and 2,130.50 equally well. (Surprising? Yes. Counterintuitive? Absolutely. Effective? Every single time.)

Step 3: Add Fiscal_Quarter
Assume your raw file has a Order_Date column in column D (D1:D927). Add this line:

raw['Order_Date'] = pd.to_datetime(raw['Order_Date'])
raw['Fiscal_Quarter'] = raw['Order_Date'].dt.quarter.map({1:'Q1', 2:'Q2', 3:'Q3', 4:'Q4'})

Now filter and select:

clean = raw[raw['Total_Amount'] >= 1500][['Order_ID', 'Customer_Name', 'Total_Amount', 'Fiscal_Quarter']].copy()

Before / After comparison (first 5 rows):

Order_ID Customer_Name Total_Amount Fiscal_Quarter
ORD-7821 Sarah Chen 2450.0 Q1
ORD-7822 Acme Corp 1890.0 Q1
ORD-7824 Nexus Labs Inc. 1670.25 Q1
ORD-7825 T. L. Kim 3012.0 Q1
ORD-7826 Vista Dynamics 2745.99 Q1

The Result

Save it directly to Excel — no manual copy-paste needed. Use this one-liner:

clean.to_excel(r"C:\Reports\Dashboard_Ready.xlsx", index=False)

That file opens in Excel instantly, formatted cleanly, with no hidden characters or merged cells. Your dashboard refreshes automatically next month when you rerun the script.

Final output (first 7 rows of Dashboard_Ready.xlsx):

Order_ID Customer_Name Total_Amount Fiscal_Quarter
ORD-7821 Sarah Chen 2450.00 Q1
ORD-7822 Acme Corp 1890.00 Q1
ORD-7824 Nexus Labs Inc. 1670.25 Q1
ORD-7825 T. L. Kim 3012.00 Q1
ORD-7826 Vista Dynamics 2745.99 Q1
ORD-7827 Luna Systems 1900.00 Q1
ORD-7828 Baxter & Sons 2280.00 Q1

What Could Go Wrong

Here are three specific mistakes we see — with clear fixes:

  • Mistake #1: Using pd.read_excel() without usecols
    You load all 23 columns just to use 4. That slows things down and risks reading corrupted formatting. Fix: Always specify usecols="A:C,E,G" or list names like usecols=["Order_ID", "Customer_Name"].
  • Mistake #2: Forgetting index=False in to_excel()
    Your exported sheet gets an extra column labeled 0, 1, 2... on the left. Looks unprofessional. Fix: Always add index=False. It’s not optional — it’s mandatory.
  • Mistake #3: Running the script while Excel has the target file open
    You’ll get a PermissionError: [Errno 13] Permission denied. Excel locks the file. Fix: Close the workbook first — or better yet, use Alt+F4 to close Excel entirely before running. (Yes, Alt+F4 still works. And yes, it saves time.)

One last thing: You don’t need to install Python globally. Download Anaconda, launch Spyder or Jupyter, and paste the code. Done.

Here’s your quick-start checklist:

Action Where Shortcut / Tip
Install pandas & openpyxl Anaconda Prompt pip install pandas openpyxl
Load raw data Python script Use usecols="A:C,D" — never blank
Clean currency One line of code Strip non-digit/non-dot — then astype(float)
Export final sheet Same script Always include index=False
Tom Bradley

Tom Bradley

Tom has 15 years of experience in office management and supply chain optimization. He shares practical tips for running efficient workplaces.