liveBook · Manning

Sales

As explained in Build Python Web Apps with Streamlit

Sales are the monetary amounts collected from completed transactions.

Sales are the dollar amount collected from completed transactions. In a dataset, each row records sales for a particular combination of date, product, customer segment, gender, age group, and state. section 6.4.1 section 6.1.2

Sales provide the basis for several dashboard metrics:

  • Total sales adds every value in the Sales column for the selected slice of data. section 6.4.1
  • Gross margin measures sales minus acquisition costs, while margin percentage expresses gross margin as a percentage of total sales. section 6.4.1
  • Average transaction value divides total sales by the number of transactions represented by the selected rows. section 6.4.1

Calculating sales metrics

For rows with sales of $500, $300, and $200, total sales equal $1,000. If gross margin totals $400, margin percentage is 40%. With 23 transactions, average transaction value is $43.48. section 6.4.1

A Python configuration can represent total sales as a metric function: df["Sales"].sum(). Related ratio metrics should guard against a zero denominator before dividing. section 6.4.2

| Date       | Product      | State |  Sales | Gross Margin | Transactions |
|------------|--------------|-------|--------|--------------|--------------|
| 2024-01-01 | Fountain Pen | CA    |    500 |          200 |           10 |
| 2024-01-01 | Notebook     | TX    |    300 |          120 |            5 |
| 2024-01-01 | Pencil       | NY    |    200 |           80 |            8 |

Inspect a small tabular dataset showing how sales, gross margin, and transactions combine into dashboard metrics. section 6.4.1

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains row-level sales, aggregate calculations, worked arithmetic, and pandas configuration while stopping short of forecasting or causal analysis.
Examples
Uses CSV rows, a three-row sales table, and Python metric functions to demonstrate aggregation.
What it assumes
Assumes tabular data and pandas DataFrames while defining sales and related metrics from basic numeric columns.
What you can do after
Apply it via pandas by summing selected Sales values and configuring the result as a dashboard metric.
How it connects
Connects sales with transactions, gross margin, margin percentage, average transaction value, and pandas DataFrames.

Also explained in

Compare how 3 books explain sales →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.