Last active
July 22, 2017 13:00
-
-
Save tpgmartin/9b0c8a94d08c53937c40495e59242289 to your computer and use it in GitHub Desktop.
Example of finding mean of multiple features in frame object grouped by custom index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.saddle._ | |
object Main { | |
def main(args: Array[String]) { | |
// Requires *.sbt file including saddle dependency to run. Run from command line with `sbt run frame.scala` | |
val height: Series[String, Double] = Series("Male" -> 6.0, "Male" -> 5.92, "Male" -> 5.58, "Male" -> 5.92, | |
"Female" -> 5.0, "Female" -> 5.5, "Female" -> 5.42, "Female" -> 5.75) | |
val weight: Series[String, Double] = Series("Male" -> 180.0, "Male" -> 190.0, "Male" -> 170.0, "Male" -> 165.0, | |
"Female" -> 100.0, "Female" -> 150.0, "Female" -> 130.0, "Female" -> 150.0) | |
val foot_size: Series[String, Double] = Series("Male" -> 12.0, "Male" -> 11.0, "Male" -> 12.0, "Male" -> 10.0, | |
"Female" -> 6.0, "Female" -> 8.0, "Female" -> 7.0, "Female" -> 9.0) | |
val data = Frame("Height" -> height, "Weight" -> weight, "Foot_Size" -> foot_size) | |
println(data.groupBy.combine(_.mean)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment