I have a dataframe which looks like below:
I need to iterate through item_1 to item_3 and then get the max value of the row and create a new column called item.
output should look like below:
What function should we use here?
I have a dataframe which looks like below:
I need to iterate through item_1 to item_3 and then get the max value of the row and create a new column called item.
output should look like below:
What function should we use here?
the function you are looking for is called greatest
df.withColumn(
"item",
greatest("item_1","item_2","item_3")
)