RE: Converting array to DF

2016-03-02 Thread Mao, Wei
der = { DataFrameHolder(_sqlContext.createDataFrame(data)) } Thanks, William From: Ashok Kumar [mailto:ashok34...@yahoo.com.INVALID] Sent: Wednesday, March 2, 2016 5:06 AM To: Shixiong(Ryan) Zhu Cc: Jeff Zhang; User Subject: Re: Converting array to DF Thanks great val weights = Array(("a"

Re: Converting array to DF

2016-03-01 Thread Ashok Kumar
Thanks great val weights = Array(("a", 3), ("b", 2), ("c", 5), ("d", 1), ("e", 9), ("f", 4), ("g", 6)) weights.toSeq.toDF("weights","value").orderBy(desc("value")).collect.foreach(println) On Tuesday, 1 March 2016, 20:52, Shixiong(Ryan) Zhu wrote: For Array,

Re: Converting array to DF

2016-03-01 Thread Shixiong(Ryan) Zhu
For Array, you need to all `toSeq` at first. Scala can convert Array to ArrayOps automatically. However, it's not a `Seq` and you need to call `toSeq` explicitly. On Tue, Mar 1, 2016 at 1:02 AM, Ashok Kumar wrote: > Thank you sir > > This works OK > import

Re: Converting array to DF

2016-03-01 Thread Jeff Zhang
Change Array to Seq and import sqlContext.implicits._ On Tue, Mar 1, 2016 at 4:38 PM, Ashok Kumar wrote: > Hi, > > I have this > > val weights = Array(("a", 3), ("b", 2), ("c", 5), ("d", 1), ("e", 9), > ("f", 4), ("g", 6)) > weights.toDF("weights","value") > > I

Converting array to DF

2016-03-01 Thread Ashok Kumar
Hi, I have this val weights = Array(("a", 3), ("b", 2), ("c", 5), ("d", 1), ("e", 9), ("f", 4), ("g", 6)) weights.toDF("weights","value") I want to convert the Array to DF but I get thisor weights: Array[(String, Int)] = Array((a,3), (b,2), (c,5), (d,1), (e,9), (f,4), (g,6)) :33: error: value