Hi Divya, You could call *collect()* method provided by DataFram API. This will give you an *Array[Rows]*. You could then iterate over this array and create your map. Something like this :
val mapOfVals = scala.collection.mutable.Map[String,String]() var rows = DataFrame.collect() rows.foreach(r => mapOfVals.put(r.getString(0), r.getString(1))) println("KEYS : " + mapOfVals.keys) println("VALS : " + mapOfVals.values) Hope this helps! [image: http://] Tariq, Mohammad about.me/mti [image: http://] <http://about.me/mti> On Wed, Mar 2, 2016 at 3:52 PM, Divya Gehlot <divya.htco...@gmail.com> wrote: > Hi, > > I need to iterate through columns in dataframe based on certain condition > and put it in map . > > Dataset > Column1 Column2 > Car Model1 > Bike Model2 > Car Model2 > Bike Model 2 > > I want to iterate through above dataframe and put it in map where car is > key and model1 and model 2 as values > > > Thanks, > Regards, > Divya > >