Thanks for your response

Actually, here is my code with when function but I still see the error

binmaster = binmasterdf.withColumnRenamed("tag_number","BinKey")\

.withColumn ("Category", when (length("Bin")==4,'SMALL LOT'), when (length("Bin")==7,'RACKING'), otherwise('FLOOR'))

Is there anything wrong with the above?

Thanks,

John