This is such a simple thing yet I'm spending hours trying to figure out, when I could easily do this in SQL or Tableau.
So imagine I have an ID column and a Item1 and Item2 column. In SQL, I'd write:
CASE
WHEN Item1 IS NULL AND Item2 IS NULL
THEN '0'
WHEN Item1 IS NOT NULL AND ITEM2 IS NOT NULL
THEN '2'
WHEN Item1 IS NULL AND Item2 is NOT NULL
THEN '1'
WHEN Item1 IS NOT NULL AND Item2 IS NULL
THEN '1'
END
Any ideas how I can replicate this in pandas? To clarify, this has to be a NEW column with values either being 0, 1 or 2.