DataFrame案例
来源:互联网 发布:四维数据能分辨男女吗 编辑:程序博客网 时间:2024/06/07 23:47
package SparkSQLDemo
import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}
/**
* Created by tg on 10/27/16.
*/
object SqlDemo {
def main(args: Array[String]): Unit = {
val conf=new SparkConf().setAppName("SqlDemo").setMaster("local")
val sc=new SparkContext(conf)
val sqlContext=new SQLContext(sc)
val df=sqlContext.read.json("file:///home/tg/datas/stus.json")
//select * from stus
df.show()
//show creat table stus
df.printSchema()
//select name from stus
df.select("name").show()
//select name,age+1 from stus
df.select(df("name"),df("age")+1).show()
//select * from stus where age >18
df.filter(df("age")>18).show()
//select count(*) from stus group by age
df.groupBy("age").count().show()
}
}
import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}
/**
* Created by tg on 10/27/16.
*/
object SqlDemo {
def main(args: Array[String]): Unit = {
val conf=new SparkConf().setAppName("SqlDemo").setMaster("local")
val sc=new SparkContext(conf)
val sqlContext=new SQLContext(sc)
val df=sqlContext.read.json("file:///home/tg/datas/stus.json")
//select * from stus
df.show()
//show creat table stus
df.printSchema()
//select name from stus
df.select("name").show()
//select name,age+1 from stus
df.select(df("name"),df("age")+1).show()
//select * from stus where age >18
df.filter(df("age")>18).show()
//select count(*) from stus group by age
df.groupBy("age").count().show()
}
}
0 0
- DataFrame案例
- RDD转换为DataFrame案例
- Spark SQL DataFrame 小案例
- 【Pandas-Cookbook】05:DataFrame框架案例
- SPARK 第4期:通过案例实战掌握spark sql(dataframe)
- Spark SQL概述,DataFrames,创建DataFrames的案例,DataFrame常用操作(DSL风格语法),sql风格语法
- dataFrame操作
- sparkSQL:dataframe
- Pandas DataFrame
- Pandas(DataFrame)
- DataFrame 排序
- Series && DataFrame
- sparksql dataframe
- SparkSQL---DataFrame
- pandas-dataframe
- DataFrame操作
- dataframe实践
- dataframe sample
- Kafka之我见
- Delphi Berlin How to have Delphi TWebbrowser component running in IE9 mode?
- nvalid content was found starting with element 'init-param'.
- 【C++面向对象】C++中运算符重载的两种方式
- 运行时异常(不需要捕捉)与一般异常有何异同(需要捕捉)
- DataFrame案例
- Java内部排序(六)-(插入排序法之折半插入排序)
- Poj 2456 Aggressive cows (二分逼近)
- Android 蓝牙客户端实现
- Centos 6 下安装 erlang 手记
- flex中DataGrid(表格)的使用
- 通过反射方式将RDD转换为DataFrame
- matplotlib 的安装
- 基础笔试编程题(jz)