Having this:
name | sex
Peter | man
Alice | woman
John | man
I want to code a function that calculate the percentage of men and women, so I've coded this:
def gender(c: Seq[df]): (Double, Double) = {
val percentages = c.groupBy(_.sex).map { case (sex, x) => val percentage = x.length * 100
/c.length}
(percentages (1), porcentages(0))
}
But I'm getting this error:
scala.collection.immutable.Iterable[Unit] does not take parameters
(percentages (1), percentages(0))
What is the problem here?