mapr-sparkml-streaming-uber's People
Forkers
sambitkumohanty183 siqueries miguelperalvo sarfarazsufi obaidpervaizgill jatin7 lucentcosmos vijaykumar243 vitycola nageswaradasari a123demi mehraraj raphy78626 batchu xtutran tashoyan pelluru rmatam mtbbiker veeranji0425 tumango mdivk mkimranbasha venkateshmohan 814417095 corersky yongtao0602mapr-sparkml-streaming-uber's Issues
unable to convert a rrd into DF()
Hi Carol,
I am using your code to do the K-means algorithm on the uber data to analyse the high demand pick up areas.
Thanks for the model . It is very well explained and coded.
I have done the K-means modelling from part 1 and now trying to fit the model with the test csv file.
I am following the code from here: https://github.com/caroljmcdonald/mapr-sparkml-streaming-uber/blob/master/src/main/scala/com/sparkkafka/uber/SparkKafkaConsumerProducer.scala I am able to convert the streaming data to rdd, but unable to convert rdd to dataframe.
scala> valuesDStream.foreachRDD {
| rdd => if (!rdd.isEmpty) {
| case class Uber(dt: String, lat: Double, lon: Double, base: String) extends Serializable
| //def parseUber(str: String): Uber = Uber(str(0), str(1).toDouble, str(2).toDouble, str(3))
| val count = rdd.count
| println("count received " + count)
| val sqlContext= new org.apache.spark.sql.SQLContext(sc)
| import sqlContext.implicits._
| rdd.collect().foreach(println)
| val df = rdd.map(_.split(",")).map(e => Uber(e(0), e(1).toDouble, e(2).toDouble, e(3)))
| val df1= sqlContext.createDataFrame(df,schema)
| df1.show()
| }
| }
<console>:72: error: overloaded method value createDataFrame with alternatives:
(data: java.util.List[_],beanClass: Class[_])org.apache.spark.sql.DataFrame <and>
(rdd: org.apache.spark.api.java.JavaRDD[_],beanClass: Class[_])org.apache.spark.sql.DataFrame <and>
(rdd: org.apache.spark.rdd.RDD[_],beanClass: Class[_])org.apache.spark.sql.DataFrame <and>
(rows: java.util.List[org.apache.spark.sql.Row],schema: org.apache.spark.sql.types.StructType)org.apache.spark.sql.DataFrame <and>
(rowRDD: org.apache.spark.api.java.JavaRDD[org.apache.spark.sql.Row],schema: org.apache.spark.sql.types.StructType)org.apache.spark.sql.DataFrame <and>
(rowRDD: org.apache.spark.rdd.RDD[org.apache.spark.sql.Row],schema: org.apache.spark.sql.types.StructType)org.apache.spark.sql.DataFrame
cannot be applied to (org.apache.spark.rdd.RDD[Uber], org.apache.spark.sql.types.StructType)
val df1= sqlContext.createDataFrame(df,schema)
Also I have tries doing this way :
`val df = rdd.map(_.split(",")).map(e => Uber(e(0), e(1).toDouble, e(2).toDouble, e(3)))
val df1 = df.toDF()`
But getting the error as :
<console>:69: error: value toDF is not a member of org.apache.spark.rdd.RDD[Uber] val df1 = df.toDF()
Any help here would be appriciated.
Thanks in advance.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.