Python for spreadsheet work: total, combine and clean exports with pandas
A free one-page Python cheat sheet for Google Colab: load pandas, total and rank customers, stack monthly exports and clean messy names and amounts.
Python for spreadsheet work: total, combine and clean exports with pandas
The three modules of the free Python for Spreadsheet Work Jump Start, practised there on real Google Colab screens.
Colab basics
- Start
- colab.research.google.com, New notebook.
- Run
- Shift+Enter runs a cell and opens a new one.
- Load
import pandas as pd- Read
sales = pd.read_csv('sales.csv')(upload it in the Files panel).
Total and rank
sales['amount'].sum()adds one column.totals = sales.groupby('customer')['amount'].sum()totals.sort_values(ascending=False)biggest first.
Combine monthly exports
- Label first:
july['month'] = 'Jul'(same for each month). quarter = pd.concat([july, august, september], ignore_index=True)quarter.groupby('month', sort=False)['amount'].sum()
Clean before you total
df['client'] = df['client'].str.strip().str.title()df['amount'] = df['amount'].str.replace(',', '').astype(int)df = df.drop_duplicates()after the clean-up, not before.
Good habits
- Show the table after every change: its name on the last line.
- Clean, then de-duplicate, then total.
- Keep the notebook: next month only the file name changes.
Remember: Write the steps once, run them on every export: same result every time, no missed rows and no double counts.
Practice it free: Python: Total a Sales Export by Customer in Google Colab at learn.ynteractive.com/modules/python-sales-report. This sheet: learn.ynteractive.com/content/cheat-sheets/python-spreadsheet-work. Lakeside Office Supply is a made-up business from the lesson. By Robert Breen, October 24, 2026.
Practice it in the free lesson
Python: Total a Sales Export by Customer in Google Colab. A beginner Python walkthrough in the free Google Colab: put six orders in a pandas table, total the quarter and rank customers by revenue, typing every line yourself. You do every step yourself in a practice copy of Google Colab, it checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, and nothing touches your real accounts.
Start the free lessonLessons on this sheet
Python: Total a Sales Export by Customer in Google ColabA beginner Python walkthrough in the free Google Colab: put six orders in a pandas table, total the quarter and rank customers by revenue, typing every line yourself.
Free · Live ~12 min Beginner
Python: Combine Monthly Sales Exports into One QuarterA beginner Python walkthrough in the free Google Colab: label three monthly exports, stack them into one quarter with pandas concat and total by month and by customer…
Free · Live ~12 min Beginner
Python: Clean a Messy Invoice Export Before You Total ItA beginner Python walkthrough in the free Google Colab: fix stray spaces and capitals, turn "1,250" text into numbers and remove a duplicate invoice before totalling…
Free · Live ~12 min Beginner
Related terms
Plain-English definitions, each with an example from a free lesson.
More cheat sheets
AI Email Responder in n8n Cheat SheetA free one-page cheat sheet: n8n watches Gmail, an AI agent reads each customer email and saves a reply as a draft in the same thread.
Lesson cheat sheet Free PDF
AI Receipt Extractor in n8n Cheat SheetA free one-page cheat sheet: attach a receipt photo in n8n chat, and an AI agent pulls the date, vendor and amount into a Google Sheets row.
Lesson cheat sheet Free PDF
ChatGPT Bank Reconciliation Cheat SheetA free one-page cheat sheet: match a bank statement CSV to the ledger with ChatGPT, list the exceptions, build the summary and check the math yourself.
Lesson cheat sheet Free PDF