spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From janardhan shetty <janardhan...@gmail.com>
Subject Re: Convert SparseVector column to Densevector column
Date Mon, 14 Nov 2016 18:00:42 GMT
This worked thanks Maropu.

On Sun, Nov 13, 2016 at 9:34 PM, Takeshi Yamamuro <linguin.m.s@gmail.com>
wrote:

> Hi,
>
> How about this?
>
> import org.apache.spark.ml.linalg._
> val toSV = udf((v: Vector) => v.toDense)
> val df = Seq((0.1, Vectors.sparse(16, Array(0, 3), Array(0.1, 0.3))),
> (0.2, Vectors.sparse(16, Array(0, 3), Array(0.1, 0.3)))).toDF("a", "b")
> df.select(toSV($"b"))
>
> // maropu
>
>
> On Mon, Nov 14, 2016 at 1:20 PM, janardhan shetty <janardhanp22@gmail.com>
> wrote:
>
>> Hi,
>>
>> Is there any easy way of converting a dataframe column from SparseVector
>> to DenseVector  using
>>
>> import org.apache.spark.ml.linalg.DenseVector API ?
>>
>> Spark ML 2.0
>>
>
>
>
> --
> ---
> Takeshi Yamamuro
>

Mime
View raw message