Skip to content
C

Problem 3: Encode Multiple Categorical Columns

Easypython

Problem Description

Write a Python program that applies One-Hot Encoding to two categorical columns ("city" and "payment_method") simultaneously in a single DataFrame.

Input

A DataFrame with two categorical columns.

Output

The DataFrame with both columns one-hot encoded.

Constraints

  • None specific.

Example Input

text
{"city": ["Delhi", "Mumbai"], "payment_method": ["Cash", "Card"]}

Example Output

text
(DataFrame with columns: city_Delhi, city_Mumbai, payment_method_Card, payment_method_Cash)

Concepts Covered

pd.get_dummies(columns=[...]).

Input (stdin)

Output

Run your code to see output here...