from pyspark.sql import SparkSession
from pyspark import SparkContext
sc = SparkContex()
rdd = sc.parallelize([('a', 1)])
hasattr(rdd, 'toDF')
spark = SparkSession(sc)
hasattr(rdd, 'toDF')
rdd.toDF().show()
'PipelinedRDD' object has no attribute 'toDF' in PySpark