user568109 user568109 - 1 year ago 156
Scala Question

How to convert rdd object to dataframe in spark

How can I convert an RDD (

) to a Dataframe
. I converted a dataframe to rdd using
. After processing it I want it back in dataframe. How can I do this ?

Answer Source

SqlContext has a number of createDataFrame methods that create a DataFrame given an RDD. I imagine one of these will work for your context.

For example:

def createDataFrame(rowRDD: RDD[Row], schema: StructType): DataFrame

Creates a DataFrame from an RDD containing Rows using the given schema.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download