I am iterating a dataframe and need to apply some custom code to each row so I'm doing this
convertedPaths.foreach { row : Row =>
cFMap = row.getValuesMap(channelSet.toSeq)
Assume that channelSet is a set of all column names. Now I've declared cFMap is of type [String, Any] as getValuesMap (as i understood would return the data type of the column)
Also, all the columns are of Long type so I was trying to do this :
channelSet.foreach { key : String =>
var frequency = cFMap.get(key).get.asInstanceOf[Double]
var value = c * frequency
given c is a variable of type Double and value needs to be a product of c and frequency but that gives me the following error :
overloaded method value * with alternatives: (x: Double)Double <and> (x: Float)Double <and> (x: Long)Double <and> (x: Int)Double <and> (x: Char)Double <and> (x: Short)Double <and> (x: Byte)Double cannot be applied to (Any)
Why is asInstanceOf[Double] not a correct solution and what could be the solution for this?