I've got a list of data that is of the structure List[((String, Double), Double)] where the columns are Car Brand, Car ID and Average price. I want to reformat this data into List[String, Map[Int, Double]]. I'm unsure where to begin.
I suspect that I'm supposed to use something like .map(car => (car.brand, car.carColor, car.purchasePrice) to split the values out, then another map to put them into the structure that I require.
The code to generate the data that I wish to reformat is as follows
val carStats = cars.groupBy(c => (c.brand,
c.carID)).mapValues(cars => car.map(_.purchasePrice).sum / cars.length).toList
I ultimately want this list to be reformatted into List[String, Map[String, Double]], but efforts so far haven't had much luck.
List[(String, Map[String, Double]]? Wouldn't it be better aMap[String, Map[String, Double]]?