There are multiple ways to create a DataFrame given rdd, you can take a look here. I’ll demonstrate the simple one.
It creates dataframe from rdd containing rows using given schema.
def createDataFrame(rowRDD: RDD[Row], schema: StructType): DataFrame
If you prefer doing it with DF Helper Function, take a look here.