Pandas → T-SQL › replace

Pandas replace to REPLACE / CASE / UPDATE

A dict {'Shipped':'S'} is CASE. A substring is REPLACE. A table of mappings is a JOIN.

CASE status
  WHEN 'Shipped' THEN 'S'
  WHEN 'Cancelled' THEN 'X'
  ELSE status
END

regex=True is PATINDEX / REPLACE loops. Usually you wanted LIKE in a WHERE, not a mutate.

Canonical translation

CASE status
  WHEN 'Shipped' THEN 'S'
  WHEN 'Cancelled' THEN 'X'
  ELSE status
END

Then write it on a ticket

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

Clock in free