7 stages2 sections22 units

01.10 Lesson 10 of 10

54 min

Visualize & Explain the Dataset

Choose a chart for a question, label it clearly and turn the analysis into a repeatable report.

By the end of this lesson

You will be able to

  • Create line, bar, histogram and scatter plots.
  • Label axes and units and include a useful title.
  • Save figures and a summary report.
  • Explain findings without claiming causation.

Match the chart to the question

Use a line chart when order or time matters, a bar chart to compare categories, a histogram to inspect a distribution and a scatter plot to inspect the relationship between two numeric variables. The chart type does not prove why a pattern exists.

import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(8, 4))
ax.plot(by_hour["hr"], by_hour["mean_rentals"])
ax.set(title="Average hourly rentals", xlabel="Hour of day", ylabel="Mean rentals")
fig.tight_layout()
fig.savefig("reports/average-rentals-by-hour.png", dpi=160)

Make the analysis reproducible

Keep data loading, auditing, transformation and plotting in small functions. Save generated files to a known output directory and write down the dataset version or file hash. A report should distinguish observations from interpretations.

from pathlib import Path

REPORT_DIR = Path("reports")
REPORT_DIR.mkdir(exist_ok=True)
summary.to_csv(REPORT_DIR / "summary.csv", index=False)

# Keep a short report with:
# - source file name and checksum
# - row/column counts
# - cleaning decisions
# - charts and observations

Apply what you learned

Exercise

Finish the Bike Sharing Dataset Explorer

Produce a small, reproducible report that explains what is in the hourly bike-sharing data and what patterns are visible.

  1. Create a report folder and save at least three charts: hourly rentals, rental-count distribution and rentals versus temperature.
  2. Include the downloaded file name, checksum and exact row count.
  3. Report dtypes, missing values, duplicate count and key column ranges.
  4. Create a grouped summary by hour and weekday.
  5. Write 3–5 observations and clearly separate observations from explanations.
Done when

A fresh run recreates the same summary files and charts from the same source file. Each chart has a title, labeled axes and a clear question it answers.

Free references

Study resources

1 links
  1. 01
    Matplotlib quick start guide Article

    Read the simple example and learn the Figure/Axes pattern.

Check your understanding

Self-test

2 questions
  1. Question 1

    Which chart is a natural first choice for the distribution of a numeric column?

  2. Question 2

    Why record a checksum for the source CSV?

Completion check

Move on when

A fresh run recreates a compact dataset report with traceable inputs, validated summaries and clearly labeled plots.

Back to module

Quick find

Search Michi

Type to search every stage, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels