Giter VIP home page Giter VIP logo

mapr-sparkml-streaming-uber's People

Contributors

caroljmcdonald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mapr-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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.