joel_iemma
New Contributor III

The way I solved it with more dynamically python was:

df = ...
cols = [(col[0], str(col[1])) for col in df.dtypes]
    void_cols = [x[0] for x in cols if x[1] == 'void']
    print(void_cols)
    
    for col in void_cols:
        df = df.withColumn(col, lit(None).cast('string'))

View solution in original post