Zum Inhalt springen

Lektion 24 · Projects and Reference

Project: Explore Cafe Sales

Practice a complete EDA on an invented cafe dataset: profile it, find planted quality problems, summarize products and weekdays, and write your findings.

In this project you run a complete exploration from raw rows to written findings. A small cafe business with two stores gives you four weeks of sales and asks: "Which products and days matter most, and can we trust this export?"

The data is invented and generated by code with a fixed seed. A few problems are planted on purpose. Work through each step, and try to predict the result before you run it.

Step 1: Meet the data

One row should be one sale line: a line ID, a date, a store, a product, a quantity and a unit price. The generator is the same in the first three steps, so each block runs on its own.

Python Generate and profile the export

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You should notice three things: there are more rows than unique line IDs, one product appears under two spellings and one quantity is far from the rest.

Step 2: Check coverage

A count per store and day reveals missing days.

Python Which store-days are missing?

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

In a real job you would now ask the owner: was the Station store closed, or did the export fail? Until you know, do not treat those days as zero sales.

Step 3: Clean with a log

Apply explicit rules and record their effect. Removing rows with a repeated line ID is safe here only because the copies are identical in every column, which the code checks. For the quantity of 200, assume that the owner confirmed an entry error and that the true value is unknown, so you exclude that line.

Python Clean, log and summarize

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Revenue per open store-day is a fairer basis than totals, because there are more weekdays than weekend days and two store-days are missing.

Step 4: Draw one clear chart

Python Daily revenue, one line per store

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

This chart uses separately invented totals so the block stays short. Its numbers do not match step 3. For your report, plot totals computed from the cleaned rows. A nan value leaves a visible break in the line, which is exactly what a gap should do.

Step 5: Write the findings

Write five lines using your output from step 3: the leading product and its revenue share, the weekday and weekend figures per open store-day, the quality problems with row counts, one limitation and one next step. Mark causes as untested. For example, you did not learn why weekends are busier.

Extensions

  1. Compare the two stores' product mix with row percentages.
  2. Recompute the results with the quantity of 200. Which conclusions change?
  3. Add a quantity distribution table per product.
  4. Load the cleaned rows into pandas and verify one total a second way.

The planted problems are easy to find because you were told that they exist. With real data, run every check even when nothing looks wrong.

What a good answer looks like

A strong submission does not just print totals. It tells the owner how many rows arrived and how many were used, which problems changed the numbers, and which questions only the owner can answer. It says plainly that two Station days are absent, so any total for Station covers fewer days. It names the fair basis for each comparison, and it avoids explaining the weekend pattern with reasons that the data does not contain.

Compare your five lines with that standard. Ask yourself whether the owner could make a mistake after reading them. If the answer is yes, add the missing caveat or base. If a line does not help any decision, remove it.

Questions for the data owner

End the project by writing the questions you would send to the owner. Ask why the Station store has no rows on two dates, how repeated line IDs could be created, whether quantities can ever be that large and whether prices include tax. Add how each possible answer would change your report. For example, if the store was closed, those days are not missing data; if the export failed, you should request the rows and run the analysis again.

Keep the questions short and specific, with dates and line IDs where relevant. An owner can answer "Were any orders taken at Station on these two dates?" much faster than "Is the data correct?"

Before you finish

Check your own report as a skeptic would. Do the product shares add up to about 100%, allowing for rounding? Does the number of rows used equal the raw count minus duplicates minus exclusions? Does the number of open store-days equal 28 days times two stores, minus the two missing ones? Each check takes a minute, and together they protect you from the most embarrassing errors.

Then rerun all blocks and compare every number in your five lines with the latest output. If you changed a rule along the way, an older figure may still be in your text. Finally, say clearly that the dataset is invented, so that nobody mistakes your practice report for facts about a real business.

Keep your log

Save your cleaning rules and row counts next to your findings, so that you can repeat the project when the owner sends a corrected export.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Why does the cleaning code compare rows before it removes a repeated line ID?

    A shared ID with different content would be a different problem that needs review.
  2. 2. Why report revenue per open store-day for weekdays and weekends?

    Totals would favor the day type with more days.
  3. 3. How should the missing Station days appear?

    Zero would claim that nothing was sold.

Summary

  • State the question and the grain, then profile rows, keys, dates and labels.
  • Check coverage across every store and day.
  • Clean with explicit rules and a row-count log.
  • Compare on a fair basis such as per open store-day.
  • Report findings, quality issues, limits and next steps.

Next: Project: Explore Bike Rentals with SQL and Python

Dein Fortschritt wird in diesem Browser gespeichert. Kein Konto nötig.