6. Analyze Sales Data and Communicate Insights

Duration4h45 AI Banned

Introduction

You will now complete an exploratory analysis of the Sales dataset and turn the retailer’s initial questions into evidence-based findings. The notebook guides the Python work, while this page organizes the analysis into meaningful milestones. At each milestone, connect the technical result to the business problem, update the project documentation, and preserve important progress with Git.

Through hands-on exercises, you will learn to:

  • Load and inspect tabular data with pandas
  • Detect missing values, duplicated rows, and invalid data types
  • Create temporal, geographic, and product-related variables
  • Aggregate transactions to answer business questions
  • Design readable visualizations with Matplotlib and Seaborn
  • Distinguish observations from interpretations and recommendations
  • Document and publish a reproducible analysis

Start from a validated project

Open notebooks/sales.ipynb, select the .venv kernel, and rerun the environment and data-loading checks from the previous activity.

In the VS Code terminal, confirm that Git does not contain unexpected changes before starting:

1
git status
Starting checkpoint

The notebook uses the .venv kernel, the CSV loads successfully, and git status shows the expected project state.

Milestone 1 — Explore the dataset structure

Complete the first notebook exercises to:

  • load sales.csv with pandas;
  • display the first and last records;
  • identify the number of rows and columns;
  • inspect column names and data types;
  • produce a concise summary of the DataFrame.

Compare the observed structure with the data description from Understand the Sales Problem. Record any difference between what you expected and what the file actually contains.

Details

Analysis question: Which variables are ready to analyze, and which ones require cleaning or conversion first?

Milestone 2 — Clean the sales records

Continue with the data-quality exercises:

  • count missing values by column;
  • inspect incomplete rows before removing or transforming them;
  • identify and remove duplicated records;
  • convert quantities and prices to numeric values;
  • convert order dates to a datetime representation;
  • verify the dataset after every transformation.

Do not apply a cleaning operation only because it is present in the notebook. Explain what problem it addresses and how it could affect later totals or charts.

When the cleaned dataset is ready, save the notebook and create a Git checkpoint:

1
2
3
git add notebooks/sales.ipynb
git commit -m "feat(data): clean sales transaction data"
git push

Milestone 3 — Create useful variables

Use the cleaned columns to create variables that answer the business questions developed in Activity 1:

  • year, month, day, and hour from the order date;
  • city or geographic information from the purchase address;
  • product categories from product names;
  • transaction revenue from quantity and unit price when relevant;
  • seasonal groupings when they support a precise question.

After creating a variable, inspect several records and its distinct values. A feature is useful only if its definition is correct and its relationship to the business question is clear.

Details

Analysis question: Which derived variables make the original business questions measurable, and which assumptions did you introduce when creating them?

Create another Git checkpoint when the feature definitions are stable:

1
2
3
git add notebooks/sales.ipynb
git commit -m "feat(features): add temporal and geographic sales features"
git push

Milestone 4 — Answer the business questions

Use filtering, grouping, aggregation, and sorting to investigate questions such as:

  1. Which months generate the highest revenue?
  2. At which hours are customers most active?
  3. Which cities generate the most transactions or revenue?
  4. Which products and categories sell the most units?
  5. How do price and ordered quantity relate?
  6. Which products are more likely to be bought together or in larger quantities?

For every result, write one sentence describing the calculation and one sentence explaining what the result means. Do not claim causation from a descriptive association.

Milestone 5 — Create and export visualizations

Select visualizations that answer a question rather than merely display all available columns. Useful candidates include:

  • monthly sales performance;
  • hourly order distribution;
  • sales by city or product category;
  • price and quantity relationship;
  • price distributions by category.

Use descriptive titles, labeled axes, readable units, and a consistent style. Export the most useful figures from the notebook into notebooks/images/:

1
2
3
4
5
6
7
plt.savefig(
    "images/monthly_sales.png",
    dpi=300,
    bbox_inches="tight",
    facecolor="white",
)
plt.show()
Choose evidence, not decoration

A good figure makes an analytical result easier to understand. Remove visual clutter and avoid adding effects that do not help the reader compare values or identify a pattern.

Commit the notebook and the selected images together:

1
2
3
git add notebooks/sales.ipynb notebooks/images/
git commit -m "feat(analysis): analyze and visualize sales patterns"
git push

Milestone 6 — Communicate the findings

Open README.md and complete the sections created earlier. The final document should contain:

  • the business context and stakeholders;
  • a concise dataset description;
  • the main research questions;
  • a short explanation of the cleaning and feature-engineering approach;
  • quantified findings supported by selected figures;
  • recommendations that follow from the evidence;
  • limitations and unanswered questions;
  • whether the dataset is included in Git and, if not, where to download it and where to save it;
  • commands for reproducing the environment and opening the notebook.

Use relative image links so they work both locally and on GitLab:

1
2
3
4
5
6
7
8
## Main Findings

### Monthly Sales Patterns

- **Finding:** [Describe and quantify the observed pattern.]
- **Business implication:** [Explain why the pattern matters.]

![Monthly Sales Performance](notebooks/images/monthly_sales.png)

The reproduction section should include at least:

1
2
3
4
git clone <PROJECT_URL>
cd sales-analysis
uv sync --locked
code .

Create the final documentation commit:

1
2
3
git add README.md
git commit -m "docs: document main sales findings"
git push

Reproduce the project from GitLab

The strongest test of reproducibility is a new copy of the repository. Ask another student to clone your project into a different directory and run:

1
2
uv sync --locked
uv run python -c "import pandas; print('Environment reproduced')"

If you chose not to track data/sales.csv, the other student must first follow the acquisition instructions in your README. They should then open the notebook, select the new .venv kernel, and execute the initial cells without copying your original virtual environment.

Final checkpoint

Another student can clone the repository, recreate .venv from pyproject.toml and uv.lock, obtain the dataset if necessary, select the kernel, load the data, and understand the main findings from the README.