# JupyterLab: Clean a Messy Sales Export and Chart Monthly Revenue

> Clean a messy sales export with pandas in a JupyterLab notebook, total revenue by month and save a bar chart. Free lesson on real JupyterLab screens.

Source: https://ynteractive.com/content/jupyterlab-clean-sales-export-monthly-revenue-chart-tutorial · Updated 2026-11-24 · Free from Stepthrough (https://ynteractive.com)

## Practice it step by step

[Start the free practice](https://ynteractive.com/modules/jupyterlab-tea-wholesaler-monthly-revenue-chart)

You do every step yourself in a practice copy of JupyterLab. It checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, about 10 minutes, and nothing touches your real accounts. [Open full screen](https://ynteractive.com/modules/jupyterlab-tea-wholesaler-monthly-revenue-chart)

Free · Live now · [AI Automation for Finance](https://ynteractive.com/courses/ai-for-finance) · JupyterLab · pandas · ~10 min · 16 steps · Beginner

Updated November 24, 2026. Built against the tool’s current screens and checked step by step. [How we check this lesson](https://ynteractive.com/content/about#how-we-check)

A monthly sales export with a blank row, an order exported twice and a TOTAL row at the bottom gives the wrong answer if you just add it up: the TOTAL row alone doubles your revenue. JupyterLab is a free notebook app where you write a few lines of [Python](https://ynteractive.com/content/glossary#python), see the result under each one and rerun the whole thing next month. In this free lesson on real JupyterLab screens, the office analyst at a made-up tea wholesaler reads the export with [pandas](https://ynteractive.com/content/glossary#pandas), finds the problems, cleans them in one cell, checks the monthly totals against the system total and saves a bar chart for the owner. 16 steps, about ten minutes.

## At a glance

| Question | Answer |
| --- | --- |
| What you build | A sales export with a blank row, a duplicated order and a TOTAL row doubles your revenue if you just add it up. Clean it in a JupyterLab notebook with pandas, total it by month, chart it and save the notebook to rerun next month, on real JupyterLab screens. |
| Tools | JupyterLab |
| Time | About 10 minutes, 16 steps in 4 parts |
| Level | Beginner, no coding needed |
| Cost | Free |
| Ways to learn it | [Practice it step by step](https://ynteractive.com/modules/jupyterlab-tea-wholesaler-monthly-revenue-chart) |

### The 4 parts, in short

1. Open the export in JupyterLab: Look at the raw export, Open the CSV in JupyterLab, Go back to the Launcher, Create a notebook.
2. Read it and find the problems: Read the export with pandas, Run the cell, Check the bottom of the file, Spot the TOTAL row.
3. Clean it in one cell: Clean the data.
4. Chart it and save: Total revenue by month, Draw the chart and save it as a picture, Save the notebook, Name the notebook, and 3 more steps.

**Start here first:** [Build an AI Agent That Categorizes Business Expenses](https://ynteractive.com/content/n8n-ai-agent-categorize-business-expenses-google-sheets) (module 1 of AI Automation for Finance)

**Part of:** [AI for Finance Teams](https://ynteractive.com/content/paths/ai-for-finance) (step 24 of 24)

**Part of:** [AI Apps Worth Knowing](https://ynteractive.com/content/paths/partner-tools-ai-apps) (step 185 of 186). Next up: [Flow XO: Turn Website Chats Into Moving-Quote Leads in a Google Sheet](https://ynteractive.com/content/flow-xo-website-chatbot-lead-capture-tutorial)

## The business case: a monthly chart that is right every time

Picture Sam, the office analyst at Kettle & Leaf Tea Co., a made-up tea wholesaler that sells to cafes and delis. Every month the order system exports sales_export.csv and the owner asks for one chart: revenue by month. This month's file has 40 rows but only 36 real orders. One row is blank, one order was exported twice, and the last row is a TOTAL of $62,684.19. Sum the Amount column as it is and the answer is more than double.

Fixing that by hand takes about half an hour each month, and it is easy to miss a row. In a JupyterLab notebook the fixes are written down once. Next month Sam drops in the new export, runs all cells and gets the chart in seconds.

## Who this is for, and what you need

Office analysts, bookkeepers, operations and finance staff who get the same export every month and build the same summary from it. The practice runs in your browser with nothing to install. To do it for real you need Python, then pip install jupyterlab pandas matplotlib, then jupyter lab in the folder with your export. All three are free and open source.

## The code, cell by cell

- Cell 1: import pandas as pd, then df = pd.read_csv("sales_export.csv"), then df.head(12).
- Cell 2: df.tail(3), which shows the TOTAL row.
- Cell 3: df = df.dropna(subset=["Order ID"]); df = df.drop_duplicates(); df["Amount"] = pd.to_numeric(df["Amount"].str.replace("[$,]", "", regex=True)); df["Order Date"] = pd.to_datetime(df["Order Date"]); len(df). It printed 36.
- Cell 4: monthly = df.groupby(df["Order Date"].dt.to_period("M"))["Amount"].sum(), then monthly.
- Cell 5: ax = monthly.plot(kind="bar", title="Monthly revenue, January to June 2026", xlabel="", ylabel="Revenue ($)", rot=0), then ax.figure.savefig("monthly_revenue.png", dpi=150, bbox_inches="tight").

## What the notebook printed

Monthly revenue came out as January 8,371.64, February 8,567.32, March 10,029.38, April 10,960.83, May 12,139.32 and June 12,615.70. Those six add up to 62,684.19, exactly the TOTAL row in the export, so the cleanup dropped nothing real and counted nothing twice. Always make that check before you send a chart.

## What this saves you

- About half an hour a month of deleting rows and retyping amounts.
- A doubled or inflated revenue number from a TOTAL row or a repeated order.
- Rebuilding the chart: next month, replace the [CSV](https://ynteractive.com/content/glossary/csv), open the notebook and choose Run, Run All Cells.
- What it does not do: it only fixes the problems you wrote code for. If the export changes shape, look at head and tail again first.

## How this lesson was built

Every practice screen is a capture of real JupyterLab 4.6.6, installed with pip install jupyterlab pandas matplotlib (pandas 3.1.1, matplotlib 3.11.2) and started with jupyter lab --no-browser on our own computer on 24 November 2026. We typed and ran every cell as shown, and every number is what the notebook printed. We ran the same steps twice, in two browsers, with the same results. Kettle & Leaf Tea Co. and its orders are made up.

## Links

- [JupyterLab docs: Get started](https://jupyterlab.readthedocs.io/en/stable/getting_started/starting.html): how to start JupyterLab with jupyter lab.
- [JupyterLab docs: Notebooks](https://jupyterlab.readthedocs.io/en/stable/user/notebook.html): creating a notebook, running cells and saving.
- [pandas docs: How do I read and write tabular data?](https://pandas.pydata.org/docs/getting_started/intro_tutorials/02_read_write.html): read_csv, head and tail.
- [pandas docs: Chart visualization](https://pandas.pydata.org/docs/user_guide/visualization.html): plot(kind="bar") and other charts.

## Try it yourself, free

Reading the steps is a start. Doing them is how it sticks. The interactive module walks you through every click in a practice copy of JupyterLab, checks each step, and never touches your real accounts.

[Start “JupyterLab: Clean a Messy Sales Export and Chart Monthly Revenue”](https://ynteractive.com/modules/jupyterlab-tea-wholesaler-monthly-revenue-chart)

## Step by step: JupyterLab: Clean a Messy Sales Export and Chart Monthly Revenue

All 16 steps of the interactive module, in order. In the module you watch each one, then do it yourself in a practice copy that checks your work.

### 1. Open the export in JupyterLab

1. **Look at the raw export.** You are Sam, the office analyst at **Kettle & Leaf Tea Co.**, a made-up tea wholesaler that sells to cafes and delis. Every month the order system exports **sales_export.csv**, and the owner wants one chart: revenue by month. The file has a blank row, an order exported twice and a **TOTAL** row at the bottom. Add up the Amount column as it is and you count everything twice. Click the file to start.
   The monthly export has a blank row, an order exported twice and a total row at the bottom. Add it up as it is and you count everything twice.
2. **Open the CSV in JupyterLab.** This is **JupyterLab**, opened with **jupyter lab** after **pip install jupyterlab pandas matplotlib**. It runs on your own computer and opens in your browser. The file browser on the left shows the folder you started it in, with **sales_export.csv** in it. Double-click **sales_export.csv**.
   This is JupyterLab, running on your own computer. Double-click sales export dot c s v.
3. **Go back to the Launcher.** JupyterLab opens the CSV as a grid. You can already see the problems: row **6** is empty, and rows **11** and **12** are the same order, **SO-10421**. Fixing these by hand every month is the half hour you are about to save. Click the **Launcher** tab.
   Row six is empty, and rows eleven and twelve are the same order.
4. **Create a notebook.** A notebook is a page of code cells. You run one cell at a time and the result appears right under it. Under **Notebook**, click **Python 3 (ipykernel)**.
   A notebook is a page of code cells, and each result appears under its cell. Under Notebook, click Python 3.

### 2. Read it and find the problems

5. **Read the export with pandas.** A new notebook, **Untitled.ipynb**, opens with one empty cell. Type three lines: load pandas, read the file into a table called **df**, and show the first 12 rows.
6. **Run the cell.** Press **Shift+Enter** to run the cell, or click the **Run** button (the triangle) in the notebook toolbar. The first run takes a few seconds while Python loads pandas.
7. **Check the bottom of the file.** The table appears under the cell. Row **5** is all **NaN**, which means empty, and rows **10** and **11** are the same order. Exports often hide something at the bottom too. In the new cell, type **df.tail(3)** and press **Shift+Enter**.
   Row five is empty and rows ten and eleven repeat. Check the bottom too.
8. **Spot the TOTAL row.** There it is: row **39** has no Order ID and says **TOTAL**, **$62,684.19**. If you summed the Amount column with that row in, your revenue would be double. Notice also the dollar signs and commas: pandas reads **Amount** as text, so it cannot add it up yet. Click the **TOTAL** row.
   Row thirty-nine is a total row. Leave it in and your revenue doubles. And the amounts are text, because of the dollar signs.

### 3. Clean it in one cell

9. **Clean the data.** One cell fixes all four problems. **dropna(subset=["Order ID"])** drops every row with no Order ID: the blank row and the TOTAL row. **drop_duplicates()** removes the order exported twice. **str.replace** strips the **$** and commas and **pd.to_numeric** turns Amount into numbers. **pd.to_datetime** turns Order Date into real dates. **len(df)** shows how many rows are left. Type it and press **Shift+Enter**.
   One cell fixes all four problems: drop rows with no order I D, drop the duplicate, turn amounts into numbers, and dates into dates.
   ```text
   df = df.dropna(subset=["Order ID"])
   df = df.drop_duplicates()
   df["Amount"] = pd.to_numeric(df["Amount"].str.replace("[$,]", "", regex=True))
   df["Order Date"] = pd.to_datetime(df["Order Date"])
   len(df)
   ```

### 4. Chart it and save

10. **Total revenue by month.** It printed **36**: 40 rows in, 36 real orders out. Now group the orders by month and add up the amounts. **dt.to_period("M")** turns each date into its month. Type it and press **Shift+Enter**.
    Forty rows in, thirty-six real orders out. Now group by month and add up the amounts.
11. **Draw the chart and save it as a picture.** Six monthly totals, from **8371.64** in January to **12615.70** in June. They add up to **62,684.19**, the same as the TOTAL row in the export, so nothing was lost or counted twice. Now chart it: **monthly.plot(kind="bar")** draws a bar chart, and **savefig** saves it as **monthly_revenue.png** for the owner. Type it and press **Shift+Enter**.
    Six monthly totals, and they add up to the export total, so nothing was lost. Now draw the bar chart and save it as a picture.
    ```text
    ax = monthly.plot(kind="bar", title="Monthly revenue, January to June 2026", xlabel="", ylabel="Revenue ($)", rot=0)
    ax.figure.savefig("monthly_revenue.png", dpi=150, bbox_inches="tight")
    ```
12. **Save the notebook.** The chart appears under the cell, and **monthly_…** appears in the file browser: that is **monthly_revenue.png**. Revenue grew every month, with the biggest jump in March. Now keep the notebook so you can rerun it next month. Press **Ctrl+S** (Cmd+S on a Mac) or click the **save** icon at the left of the notebook toolbar.
    The chart is under the cell, and the picture is in the file browser. Save the notebook so you can rerun it next month.
13. **Name the notebook.** The first save asks you to **Rename file**. **Untitled** is selected, so typing replaces it and keeps **.ipynb**. Type **monthly_revenue**.
    The first save asks for a name.
14. **Rename and Save.** Click **Rename and Save**.
15. **Open the chart file.** The tab now says **monthly_revenue.ipynb**, and the file browser lists the notebook, the chart and the export. Double-click **monthly_revenue.png**, the file with the picture icon, to check what the owner will get.
    Saved. Double-click the chart picture to check what the owner will get.
16. **Check the chart.** This is the saved file: **Monthly revenue, January to June 2026**, one bar per month. Next month, put the new export in the same folder with the same name, open **monthly_revenue.ipynb**, choose **Run**, **Run All Cells**, and the chart is redrawn in seconds. Click the chart.
    This is the file the owner gets. Next month, drop in the new export and run all cells.

## Frequently asked questions

**What is JupyterLab?**

JupyterLab is a free, open-source notebook app from Project Jupyter. You write code in cells, run each one and see the result, such as a table or a chart, right under it. It runs on your computer and opens in your browser.

**How do I install and start JupyterLab?**

With Python installed, run pip install jupyterlab (we also installed pandas and matplotlib), then run jupyter lab in the folder with your files. It opens in your browser. Add --no-browser to start it without opening a browser tab.

**How do I remove blank rows and duplicates from a CSV with pandas?**

Read it with pd.read_csv, then df.dropna(subset=["Order ID"]) drops rows with no ID, which also removes a TOTAL row with no ID, and df.drop_duplicates() removes rows that are exactly the same.

**Why can't pandas add up my amounts?**

Amounts with a dollar sign and commas, like $1,371.26, are read as text. Strip the symbols with str.replace("[$,]", "", regex=True) and convert with pd.to_numeric.

**How do I chart monthly totals in JupyterLab?**

Convert the date column with pd.to_datetime, group with df.groupby(df["Order Date"].dt.to_period("M"))["Amount"].sum(), then call .plot(kind="bar"). The chart appears under the cell, and ax.figure.savefig saves it as a PNG.

**Was this lesson made in the real tool?**

Yes. Every screen is a capture of real JupyterLab 4.6.6 from 24 November 2026, and every output is what the cells printed. Buttons and labels may move in later versions.

[Start this module free](https://ynteractive.com/modules/jupyterlab-tea-wholesaler-monthly-revenue-chart)

- Previous in AI Automation for Finance: [Docparser: Pull Invoice Data from PDFs into a Spreadsheet](https://ynteractive.com/content/docparser-extract-invoice-data-pdf-to-spreadsheet)

## More in AI Automation for Finance

- [Build an AI Agent That Categorizes Business Expenses](https://ynteractive.com/content/n8n-ai-agent-categorize-business-expenses-google-sheets): Build an AI agent for Maple Street Bookkeeping that sorts business expenses into categories, writes a short note for each and saves them to Google Sheets — chat…
- [Build an Expense Reimbursement Form With AI Policy Checks](https://ynteractive.com/content/expense-reimbursement-form-ai-approval-lovable-n8n): Build an expense reimbursement form in Lovable for Maple Street Bookkeeping and connect it to n8n — the AI agent checks each request against the policy, saves it to…
- [How to Put PDF Invoices in Google Sheets with n8n, AI and an Approval Step](https://ynteractive.com/content/invoice-inbox-to-google-sheets-approval-n8n): Build an n8n workflow that reads each vendor invoice PDF from Gmail with AI, logs the vendor, invoice number and total in Google Sheets, and emails the owner an Approve…

[All 5 modules in AI Automation for Finance](https://ynteractive.com/courses/ai-for-finance)

## Terms in this lesson

Plain-English definitions, each with an example from a free lesson.

[Python](https://ynteractive.com/content/glossary#python) · [pandas (Python)](https://ynteractive.com/content/glossary#pandas) · [CSV](https://ynteractive.com/content/glossary/csv) · [GROUP BY (SQL)](https://ynteractive.com/content/glossary#group-by)

[The full AI glossary](https://ynteractive.com/content/glossary)

## Browse related tutorials

[AI for Finance (5)](https://ynteractive.com/courses/ai-for-finance)

**Get the badge / embed this lesson**
