🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Data Science & Analytics › Python and R for Data Science & Analytics › Lesson 9
TEC-DATA85-03 · Lesson 9 · 11 clock hours · lab

Integrated Python/R Mini-Project: End-to-End Analytical Script

Objective. Students independently design, code, document, and present a short end-to-end analytical script in their choice of Python or R that answers a defined question from a provided real-world dataset.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Integrated Python/R Mini-Project: End-to-End Analytical Script

Why End-to-End Thinking Matters

A data analyst's job does not stop at writing a clever line of code. Employers expect you to move a dataset from raw form all the way through cleaning, analysis, and communication — without anyone else having to fix your work in between. This lab asks you to do exactly that: pick a real dataset, ask a focused question, write a script that answers it, and explain your reasoning to a peer audience. That sequence mirrors what Google, IBM, and CompTIA all test: the ability to plan, execute, and communicate an analytical workflow.

Step 1 — Write the Problem Statement First

Before you open a notebook or an RStudio session, write one paragraph that answers three questions: What is the analytical question? Who will read the output? What form will the output take (table, chart, report)? This document is not busywork — it is your contract with yourself. Analysts who skip this step often produce technically correct code that answers the wrong question. Keep the problem statement in a plain text or Markdown file and commit it to your repository before writing a single line of code.

Example structure: "Using the public transit ridership dataset, this script will determine whether weekday ridership on the three busiest routes increased or decreased between the first and last full months in the dataset. The output is intended for a transit operations manager and will be delivered as a CSV summary table and a short formatted text report."

Step 2 — Import and Inspect the Data

Load your chosen dataset using `pandas.read_csv()` in Python or `read.csv()` / `readr::read_csv()` in R. Immediately inspect shape, column names, and data types. Look for obvious problems before you start cleaning:

Document every issue you find in your lab log. You are required to fix at least two column-level issues. A "column-level issue" means something that affects the values in one specific column — for example, converting a date string column to a proper datetime type, or stripping leading/trailing spaces from a text field.

Step 3 — Write a Named Function with a Docstring

Your main transformation step must live inside a function that has a docstring. A docstring explains what the function does, what arguments it accepts, and what it returns. This is not optional style — it is how professional code is documented and how peer reviewers and future maintainers understand your logic without reading every line.

In Python, the docstring sits immediately inside the `def` block, enclosed in triple quotes. In R, a roxygen2-style comment block above the function serves the same purpose. Keeping transformation logic in a function also makes your script testable: you can call the function on a small sample and verify the output before running it on the full dataset.

Step 4 — Compute Summary Statistics and Export Outputs

Compute at least three summary statistics relevant to your question. These might include counts, means, medians, percent changes, or group-level aggregations — whatever the problem statement calls for. Round final values to a reasonable number of decimal places and label every column clearly.

Export two outputs:

1. A CSV file — use `df.to_csv('output.csv', index=False)` in Python or `write.csv(df, 'output.csv', row.names = FALSE)` in R.

2. A formatted text report — a plain `.txt` file that a non-technical stakeholder can open and read without knowing anything about code. Use `f-strings` or `format()` in Python, or `cat()` / `sprintf()` in R to build readable sentences around your numbers.

Both files must be written programmatically by your script — not manually created after the fact.

Step 5 — Version Control with Git/GitHub

Commit your work at logical checkpoints: after the problem statement, after the cleaning step, after the function is written, and after the final outputs are generated. Each commit message should be a short, honest description of what changed. When you submit the final revision after peer review, include a changelog comment at the top of your script or notebook explaining what you changed and why. This trains the habit employers look for: traceable, explainable work.

Step 6 — Peer Walkthrough and Revision

Deliver a five-minute walkthrough to two classmates acting as stakeholder reviewers. Walk through the problem statement, the key cleaning decisions, the function, and the final outputs. Invite at least two clarifying questions and answer them directly. After the session, note the feedback in your lab log and decide what to revise. Even if a reviewer's suggestion does not change your code, document why you accepted or declined it. Documented reasoning is evidence of professional judgment.

Data Safety and Responsible Handling

Even public datasets can contain personally identifiable information (PII) — names, addresses, transit card IDs, or account numbers included by accident. Before you begin analysis, scan for any columns that could identify individuals and confirm with your instructor that the dataset has been cleared for student use as provided. Do not post raw datasets to public GitHub repositories without instructor approval. Handle data files on school systems only, following your program's acceptable-use policy.

Pass Criteria

Your script must run end-to-end on the instructor's machine without manual edits, meaning no hard-coded file paths that only work on your computer. Use relative paths. The problem statement, the docstring function, the CSV export, and the peer-review documentation must all be present. Every element is required — meeting most of them is not a pass.

Key terms8

Problem statementA written paragraph drafted before coding that defines the analytical question, the intended audience, and the expected output format; it serves as the analyst's guiding contract for a project.
Column-level issueA data quality problem that affects the values stored in one specific column, such as an incorrect data type, inconsistent formatting, or unexpected missing values.
DocstringA string literal placed immediately inside a Python function definition (or an equivalent comment block in R) that documents what the function does, its parameters, and its return value.
End-to-end scriptA script or notebook that performs every stage of an analytical workflow — import, cleaning, analysis, and output — without requiring manual steps between stages.
Summary statisticA single numerical value that describes a feature of a dataset, such as a count, mean, median, or percent change, used to communicate key findings concisely.
Changelog commentA documented note in a script or commit message that explains what was changed from a previous version and why, supporting traceability and peer review.
Relative pathA file path expressed relative to the script's current working directory rather than a fixed location on one machine, so the code runs correctly on any computer with the same folder structure.
Personally identifiable information (PII)Any data element that could be used alone or in combination to identify a specific individual, such as a name, address, or account number; must be handled with care even in public datasets.
In class: Select one of three provided real-world datasets (public transit ridership, local weather records, or municipal budget allocations); write a one-paragraph problem statement specifying the analytical question, the intended audience, and the output format before any coding begins. · Build the complete script or notebook: import data, clean at least two column-level issues, compute at least three summary statistics, and write the final summary table to a CSV and a formatted text report; include a function with a docstring for the main transformation step. · Deliver a 5-minute live walkthrough to two classmates acting as stakeholder reviewers; respond to at least two clarifying questions; incorporate reviewer feedback into a final revision submitted to the course repository with a changelog comment.
Materials: Jupyter Notebook or RStudio (student choice), three provided datasets, Git/GitHub, lab log, peer-review rubric
Check: Script runs end-to-end without manual edits on instructor machine; problem statement on file; at least one function with docstring present; summary table exported correctly; peer-review responses documented — maps to Google Data Analytics, IBM Data Science, and CompTIA Data+ applied-programming domains; all criteria required for pass.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Google Data Analytics — data-driven decision making and project planning
1. A student writes the problem statement after finishing the cleaning step. What is the primary risk of this approach?
IBM Data Science Professional — Python programming and data wrangling
2. Which Python code correctly exports a DataFrame named `results` to a CSV without writing the row index?
CompTIA Data+ — data management and scripting best practices
3. A student's script uses the absolute path `C:/Users/Jordan/Desktop/data.csv` to load the dataset. What problem does this cause?
IBM Data Science Professional — Python programming conventions
4. Which of the following best describes a docstring in a Python function?
Google Data Analytics — analytical thinking and communicating findings
5. During a peer walkthrough, a reviewer asks why a student converted the `date` column from string to datetime format. The student has no documented reason. What does this reveal about the student's workflow?
CompTIA Data+ — data quality and data types
6. A student notices a column labeled `passenger_count` is stored as the object (string) data type instead of integer. This is an example of which type of issue?
Google Data Analytics — communicating with stakeholders and iterating on findings
7. After the peer walkthrough, a reviewer suggests displaying median ridership instead of mean ridership because the data contains outliers. The student disagrees but does not change the script. What must the student include in the final submission?
IBM Data Science Professional — data ethics and responsible data handling
8. A student is about to upload the raw municipal budget dataset to a public GitHub repository. What should the student do first?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.