Skip to content
CampusEduX

Problem 4: Compare Original and Encoded Data

Easypython
Learn the Concept: Encoding Categorical Data

Problem Description

Write a Python program that takes a categorical "size" column ("Small," "Medium," "Large"), applies Label Encoding respecting the correct order, and prints a side-by-side comparison of the original and encoded values.

Input

A DataFrame with a "size" column.

Output

A side-by-side view of the original and encoded "size" values.

Constraints

  • Only these three size values will appear.

Example Input

text
{"size": ["Medium", "Small", "Large"]}

Example Output

text
size size_encoded 0 Medium 1 1 Small 0 2 Large 2

Concepts Covered

Custom ordinal mapping, .map(), DataFrame comparison.

Related Problems

  • Problem 1: Apply One-Hot Encoding to a Column
    Easy · python
    Solve Problem
  • Problem 2: Apply Label Encoding with a Custom Order
    Easy · python
    Solve Problem
  • Problem 3: Encode Multiple Categorical Columns
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...