Skip to content
C

Problem 4: Apply a Custom Function to Flag Values

Easypython

Problem Description

Write a Python program that uses apply() with a custom function to create a new column flagging whether each order amount is "High" (>150) or "Low" (<=150).

Input

A DataFrame with an "amount" column.

Output

The DataFrame with a new "amount_flag" column.

Constraints

  • None specific.

Example Input

text
{"amount": [100, 200, 150, 300]}

Example Output

text
amount amount_flag 0 100 Low 1 200 High 2 150 Low 3 300 High

Concepts Covered

apply(), lambda, conditional logic.

Input (stdin)

Output

Run your code to see output here...