Module Assessment
Overview
Congratulations on completing the Manipulating Data with Pandas module! You've learned how to load data from files, explore DataFrames, select and filter rows and columns, transform values with mapping functions, and summarize data with grouping and sorting. This assessment brings all of those skills together in a realistic data wrangling project.
Complete the assessment using this Colaboratory notebook.
Learning Objective
By the end of this assessment, you will have demonstrated your ability to:
- Perform data wrangling tasks on a sample dataset.
- Demonstrate ability to read, transform, and output results.
Key terms
Data wrangling: The process of cleaning, reshaping, and transforming raw data into a format suitable for analysis. Also called data munging.
Pipeline: A sequence of data transformation steps applied in order, where the output of each step becomes the input of the next.
Aggregated output: A summary result derived from grouping raw records, such as totals, averages, or counts per category.
Assessment Overview
This module assessment is a coding project completed in a Google Colaboratory notebook. You will be given a raw CSV dataset and complete a series of tasks that exercise the full Pandas workflow — from loading and exploring the data to cleaning, transforming, and summarizing it.
Skills Assessed
| Skill | Lesson |
|---|---|
| Loading data from a CSV file | Creating, Reading, and Writing |
| Exploring DataFrame structure | Introduction to Pandas |
| Selecting columns and filtering rows | Selecting and Assigning |
| Creating derived columns | Selecting and Assigning |
Transforming values with .map() and .apply() | Mapping Data |
| Grouping and aggregating | Grouping and Sorting |
| Sorting and ranking results | Grouping and Sorting |
| Writing output to a CSV file | Creating, Reading, and Writing |
Coding Assessment
Complete the project in this notebook. The notebook contains a series of guided tasks. After completing all tasks, save your notebook to GitHub and submit the link for grading.
Task Overview
The notebook will walk you through the following steps using a provided retail sales dataset:
-
Load and inspect — Read the CSV file into a DataFrame. Display the shape, column types, and first 10 rows. Identify any missing values with
.isnull().sum(). -
Select and explore — Select only the columns relevant to the analysis. Filter rows to keep only records from the last two years. Use
.describe()to summarize the numeric columns. -
Clean and assign — Standardize a string column (trim whitespace and apply
.title()case). Use.map()ornp.where()to create a new categorical column based on a numeric threshold. -
Transform with
.apply()— Write a function and apply it row-wise (axis=1) to derive a new column that depends on values from two or more existing columns. -
Group and aggregate — Use
groupby()and.agg()to produce a summary table showing total sales, average order value, and transaction count for each product category. -
Sort and rank — Sort the summary table to identify the top-performing categories. Use
.nlargest()to extract the top 5 individual transactions. -
Write output — Save the summary table and the cleaned full dataset to separate CSV files using
to_csv().
Grading Rubric
| Criteria | Points |
|---|---|
| Data loaded correctly and explored with appropriate methods | 10 |
| Correct columns selected; rows filtered without errors | 15 |
| String cleaning and new categorical column created correctly | 15 |
Row-wise .apply() function produces correct results | 15 |
groupby().agg() summary is accurate and readable | 20 |
| Sort and ranking steps are correct | 10 |
Output files saved with index=False | 5 |
| Code is clean, readable, and uses descriptive variable names | 10 |
| Total | 100 |
Knowledge Check
df["discount"] = df.apply(lambda x: x["price"] * 0.1)