Fundamentals 4 min read

Convert Excel Scores to Grade Levels Using Python Pandas

This article explains how to transform numeric scores in multiple Excel sheets into categorical grades (Excellent, Good, Average, Poor) with Python, preserving any existing Chinese text, and provides a concise, reusable solution illustrated with screenshots.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Convert Excel Scores to Grade Levels Using Python Pandas

1. Introduction

Hello, I am PiPi. Recently, a request was shared in a Python community to convert numeric scores in three Excel sheets into four grade categories: 100 points as "Excellent", 80‑99 as "Good", 60‑79 as "Average", and below 60 as "Poor". Any existing Chinese text in the cells should be retained (e.g., "Chinese 100" becomes "Chinese Excellent").

2. Implementation

The solution builds on a previous method that used a clean and efficient code snippet to address similar data‑processing tasks. Below are the key steps and screenshots demonstrating the approach:

Another method, provided by a contributor, works uniformly across all three sheets, avoiding the need for separate handling of each sheet.

The technique uses pandas' cut function (or an equivalent custom mapping) to map numeric ranges to the desired grade labels while preserving any non‑numeric characters.

3. Summary

This article presented a practical Python automation solution for converting scores to grade levels in Excel files, offering clear code and visual guidance to help readers apply the method to similar data‑analysis problems.

Additional tips: when sharing large datasets, anonymize sensitive data, provide a small demo file, and include error screenshots. For longer scripts (over 50 lines), attach a .py file.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonExcelpandas
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.