user14736700
user14736700

Reputation:

How to adapt the following data transformation from pyspark to scala

Doing the following transformation in pyspark.how can I adapt in to scala?

accept_value= when(col("column1") < 0.9, 1).otherwise(0)

Upvotes: 1

Views: 104

Answers (1)

Sudhin
Sudhin

Reputation: 149

you can write something like this in scala.

import org.apache.spark.sql.functions.{col,when}
val accept_value = df.withColumn("converted_value", when(col("number").lt(0.9), 1).otherwise(0))

pyspark for reference:

from pyspark.sql.functions import col, when
accept_value = df.withColumn("converted_value",when(col("number") < 0.9, 1).otherwise(0))

Upvotes: 2

Related Questions