Students often ask me what Python is actually for in commerce. The easiest answer is to show it. Below are five questions a manager might ask about a year of sales data, and the few lines of Python that answer each. The file, sales.xlsx, has one row per invoice: date, region, product, quantity and amount.
import pandas as pd
sales = pd.read_excel("sales.xlsx")
That one line reads the whole file, however many rows it has.
1. Which region sells the most?
sales.groupby("region")["amount"].sum().sort_values(ascending=False)
In Excel this is a pivot table. In Python it is one line, and it gives the same answer next month when the file changes.
2. How are sales moving month by month?
sales["month"] = sales["date"].dt.to_period("M")
sales.groupby("month")["amount"].sum().plot()
Two lines, and you have a trend chart.
3. Which ten products bring in the most revenue?
sales.groupby("product")["amount"].sum().nlargest(10)
4. Are there duplicate or missing entries?
sales.duplicated().sum()
sales.isna().sum()
The first counts repeated rows; the second shows how many blanks each column has. Checking this before any analysis is what separates a careful analyst from a careless one.
5. What is the average order value in each region?
sales.groupby("region")["amount"].mean().round(2)
What this shows
None of these is advanced. They are the questions any commerce graduate already understands, asked of more data than Excel handles comfortably, and answered the same way every time. Learning to write lines like these, and to explain what they show, is most of what a first analytics job asks for.
This is the ground the first three weeks of Business Data Analytics with Python cover, before we move on to charts, regression and a final project.