many thx Nick
kr
On Thu, Apr 28, 2016 at 8:07 PM, Nick Pentreath
wrote:
> This should work:
>
> scala> val df = Seq((25.0, "foo"), (30.0, "bar")).toDF("age", "name")
> scala> df.withColumn("AgeInt", when(col("age") > 29.0,
> 1).otherwise(0)).show
> +++--+
This should work:
scala> val df = Seq((25.0, "foo"), (30.0, "bar")).toDF("age", "name")
scala> df.withColumn("AgeInt", when(col("age") > 29.0, 1).otherwise(0)).show
+++--+
| age|name|AgeInt|
+++--+
|25.0| foo| 0|
|30.0| bar| 1|
+++--+
On Thu, 28 Apr 2016 at
HI all
i have a dataFrame with a column ("Age", type double) and i am trying to
create a new
column based on the value of the Age column, using Scala API
this code keeps on complaining
scala> df.withColumn("AgeInt", if (df("Age") > 29.0) lit(1) else lit(0))
:28: error: type mismatch;
found :