pyspark : NameError: name ‘spark’ is not defined

You can add

from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
sc = SparkContext('local')
spark = SparkSession(sc)

to the begining of your code to define a SparkSession, then the spark.createDataFrame() should work.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)