TypeError : withcolumn() takes 3 positional arguments but 4 were given.

JohnJustus
New Contributor III

Hi All,

Can some one please help me with the error.

This is my small python code.

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

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

TypeError : withcolumn() takes 3 positional arguments but 4 were given.

If I remove this (length("Bin")==7,'RACKING'), there are no issues.

Can some one please let me know how to fix the error?

Thanks,

John