01.10 Lesson 10 of 10
54 minVisualize & 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
ExerciseFinish 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.
- Create a report folder and save at least three charts: hourly rentals, rental-count distribution and rentals versus temperature.
- Include the downloaded file name, checksum and exact row count.
- Report dtypes, missing values, duplicate count and key column ranges.
- Create a grouped summary by hour and weekday.
- Write 3–5 observations and clearly separate observations from explanations.
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
- 01
Check your understanding
Self-test
-
Question 1
Which chart is a natural first choice for the distribution of a numeric column?
A histogram, because it groups numeric values into bins and displays their frequency. -
Question 2
Why record a checksum for the source CSV?
It identifies the exact file snapshot used, even if a repository later changes its file or metadata.
Completion check
Move on when
A fresh run recreates a compact dataset report with traceable inputs, validated summaries and clearly labeled plots.