Adding constant value column to spark dataframe
muon@ provided the correct answer above. Just adding a quick reproducible version to increase clarity.
>>> from pyspark.sql.functions import lit
>>> df = spark.createDataFrame([(1, 4, 3)], ['a', 'b', 'c'])
>>> df.show()
+---+---+---+
| a| b| c|
+---+---+---+
| 1| 4| 3|
+---+---+---+
>>> df = df.withColumn("d", lit(5))
>>> df.show()
+---+---+---+---+
| a| b| c| d|
+---+---+---+---+
| 1| 4| 3| 5|
+---+---+---+---+
you need to import lit
either
from pyspark.sql.functions import *
will make lit
available
or something like
import pyspark.sql.functions as sf
wamp = wamp.withColumn('region', sf.lit('NE'))