How to Solve NameError: name 'when' is not defined -- pyspark
Solution: Import the 'when' module
To Solve the error, add the following line to the top of your code.
from pyspark.sql.functions import when
For more information:
Python pyspark when