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 <[email protected]> wrote: > Thank you sir > > This works OK > import sqlContext.implicits._ > val weights = Seq(("a", 3), ("b", 2), ("c", 5), ("d", 1), ("e", 9), ("f", > 4), ("g", 6)) > > weights.toDF("weights","value").orderBy(desc("value")).collect.foreach(println) > > Please why Array did not work? > > > On Tuesday, 1 March 2016, 8:51, Jeff Zhang <[email protected]> wrote: > > > Change Array to Seq and import sqlContext.implicits._ > > > > On Tue, Mar 1, 2016 at 4:38 PM, Ashok Kumar <[email protected]> > 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 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)) > <console>:33: error: value toDF is not a member of Array[(String, Int)] > weights.toDF("weights","value") > > I want to label columns and print out the contents in value order please I > don't know why I am getting this error > > Thanks > > > > > -- > Best Regards > > Jeff Zhang > > >
