many thx Nick kr
On Thu, Apr 28, 2016 at 8:07 PM, Nick Pentreath <nick.pentre...@gmail.com> 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 > +----+----+------+ > | age|name|AgeInt| > +----+----+------+ > |25.0| foo| 0| > |30.0| bar| 1| > +----+----+------+ > > On Thu, 28 Apr 2016 at 20:45 Marco Mistroni <mmistr...@gmail.com> wrote: > >> 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)) >> <console>:28: error: type mismatch; >> found : org.apache.spark.sql.Column >> required: Boolean >> df.withColumn("AgeInt", if (df("Age") > 29.0) lit(1) else >> lit(0)) >> >> any suggestions? >> >> kind regars >> marco >> >