How to calculate the mean of a dataframe column and find the top 10%
This is the import you need, and how to get the mean for a column named "RBIs":

import org.apache.spark.sql.functions._
df.select(avg($"RBIs")).show()


For the standard deviation, see
scala - Calculate the standard deviation of grouped data in a Spark DataFrame - Stack Overflow

For grouping by percentiles, I suggest defining a new column via a user-defined function (UDF), and using groupBy on that column.  See


Spark SQL and DataFrames - Spark 1.5.1 Documentation - udf registration