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

SkillLesson
Loading data from a CSV fileCreating, Reading, and Writing
Exploring DataFrame structureIntroduction to Pandas
Selecting columns and filtering rowsSelecting and Assigning
Creating derived columnsSelecting and Assigning
Transforming values with .map() and .apply()Mapping Data
Grouping and aggregatingGrouping and Sorting
Sorting and ranking resultsGrouping and Sorting
Writing output to a CSV fileCreating, 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:

  1. 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().

  2. 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.

  3. Clean and assign — Standardize a string column (trim whitespace and apply .title() case). Use .map() or np.where() to create a new categorical column based on a numeric threshold.

  4. 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.

  5. 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.

  6. Sort and rank — Sort the summary table to identify the top-performing categories. Use .nlargest() to extract the top 5 individual transactions.

  7. Write output — Save the summary table and the cleaned full dataset to separate CSV files using to_csv().

Grading Rubric

CriteriaPoints
Data loaded correctly and explored with appropriate methods10
Correct columns selected; rows filtered without errors15
String cleaning and new categorical column created correctly15
Row-wise .apply() function produces correct results15
groupby().agg() summary is accurate and readable20
Sort and ranking steps are correct10
Output files saved with index=False5
Code is clean, readable, and uses descriptive variable names10
Total100

Knowledge Check

Question 1: Which Pandas method is most appropriate for quickly detecting missing values across all columns?

Question 2: A teammate wrote the following code. What is the most likely problem?
df["discount"] = df.apply(lambda x: x["price"] * 0.1)

Question 3: After running `df.groupby("category")["revenue"].sum()`, the result has `category` as the index. What is the standard next step to make the result easier to work with?