Pandas apply to CASE / a scalar function

If the lambda is if/else, it is CASE. If it calls a library, do it in the app after the SELECT.

CASE WHEN total_amount > 10000 THEN 'A' ELSE 'B' END AS tier

apply axis=1 over a million rows is why the notebook timed out. SQL CASE will not.

Canonical translation

CASE WHEN total_amount > 10000 THEN 'A' ELSE 'B' END AS tier

Then write it on a ticket

Monday is free. A colleague asks, you type, we mark it.

Clock in free