Search code examples
pythonpysparkapache-spark-sqlrdd

Add empty column to dataframe in Spark with python


I have a dataframe that I want to make a unionAll with another dataframe. The problem is that the second dataframe has three more columns than the first one. Is there a way for me to add three columns with only empty cells in my first dataframe?


Solution

  • df.withColumn('NewColumn', lit(None).cast(StringType()))