0

I have the following list:

columns = [('url','string'),('count','bigint'),('isindex','boolean')]

I want to add this columns to my df with empty values:

for column in columns:
df = df.withColumn(column[0], f.lit(?).cast(?))

I am not sure what I need to put in the lit function and in the cast in order to have the suitable empty value for each type

Thank you!

dasilva555
  • 93
  • 1
  • 2
  • 12
  • 1
    Does this answer your question? [Add an empty column to Spark DataFrame](https://stackoverflow.com/questions/33038686/add-an-empty-column-to-spark-dataframe) – mck Feb 25 '21 at 17:45
  • No because the answer is for specific type – dasilva555 Feb 25 '21 at 17:55
  • 1
    [This answer](https://stackoverflow.com/a/66267256/14165730) is more similar to what you want to do – mck Feb 25 '21 at 18:02

0 Answers0