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?
Maybe this will help
To add string type column:
from pyspark.sql.types import StringType
df.withColumn("COL_NAME", lit(None).cast(StringType()))
To Add integer type
from pyspark.sql.types import IntegerType
df.withColumn("COL_NAME", lit(0).cast(IntegerType()))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With