Wednesday, July 15, 2020

Real Python: Pandas Project: Make a Gradebook With Pandas

One of the jobs that all teachers have in common is evaluating students. Whether you use exams, homework assignments, quizzes, or projects, you usually have to turn students’ scores into a letter grade at the end of the term. This often involves a bunch of calculations that you might do in a spreadsheet. Instead, you can consider using Python and pandas.

One problem with using a spreadsheet is that it can be hard to see when you make a mistake in a formula. Maybe you selected the wrong column and put quizzes where exams should go. Maybe you found the maximum of two incorrect values. To solve this problem, you can use Python and pandas to do all your calculations and find and fix those mistakes much faster.

In this tutorial, you’ll learn how to:

  • Load and merge data from multiple sources with pandas
  • Filter and group data in a pandas DataFrame
  • Calculate and plot grades in a pandas DataFrame

Click the link below to download the code for this pandas project and follow along as you build your gradebook script:

Get the Source Code: Click here to get the source code you'll use to build a gradebook with pandas in this tutorial.

Build It: In this tutorial, you’ll build a full project from start to finish. If you’d like to learn more about pandas, then check out the pandas learning path.

Demo: What You’ll Build

In this pandas project, you’re going to create a Python script that loads your grade data and calculates letter grades for your students. Check out this video for a demonstration of the script in action:

Your script will run from the command line or your IDE and will produce CSV output files so you can paste the grades into your school’s grading system. You’ll also produce a few plots to take a look at how your grades are distributed.

Project Overview

This pandas project involves four main steps:

  1. Explore the data you’ll use in the project to determine which format and data you’ll need to calculate your final grades.
  2. Load the data into pandas DataFrames, making sure to connect the grades for the same student across all your data sources.
  3. Calculate the final grades and save them as CSV files.
  4. Plot the grade distribution and explore how the grades vary among your students.

Once you complete these steps, you’ll have a working Python script that can calculate your grades. Your grades will be in a format that you should be able to upload to your school’s student administration system.

Background Reading

You’ll get the most out of this pandas project if you have a little bit of experience working with pandas. If you need a refresher, then these tutorials and courses will get you up to speed for this project:

Don’t worry too much about memorizing all the details in those tutorials. You’ll see a practical application of the topics in this pandas project. Now let’s take a look at the data you’ll be using in this project!

Exploring the Data for This Pandas Project

Like most teachers, you probably used a variety of services to manage your class this term, including:

  • The school’s student administration system
  • A service to manage assigning and grading homework and exams
  • A service to manage assigning and grading quizzes

For the purposes of this project, you’ll use sample data that represents what you might get out of these systems. The data is in comma-separated values (CSV) files. Some samples of the data are shown here. First, there’s a file that contains the roster information for the class. This would come from your student administration system:

ID Name NetID Email Address Section
1234567 “Barrera Jr., Woody” WXB12345 WOODY.BARRERA_JR@UNIV.EDU 1
2345678 “Lambert, Malaika” MXL12345 MALAIKA.LAMBERT@UNIV.EDU 2
3456789 “Joyce, Traci” TXJ12345 TRACI.JOYCE@UNIV.EDU 1
4567890 “Flower, John Gregg” JGF12345 JOHN.G.2.FLOWER@UNIV.EDU 3

This table indicates each student’s ID number, name, NetID, and email address as well as the section of the class that they belong to. In this term, you taught one class that met at different times, and each class time has a different section number.

Read the full article at https://realpython.com/pandas-project-gradebook/ »


[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...