I have a multi-column pyspark dataframe, and I need to convert the string types to the correct types, for example:
I'm doing like this currently
df = df.withColumn(col_name, col(col_name).cast('float') \
.withColumn(col_id, col(col_id).cast('int') \
.withColumn(col_city, col(col_city).cast('string') \
.withColumn(col_date, col(col_date).cast('date') \
.withColumn(col_code, col(col_code).cast('bigint')
is it possible to create a list with the types and pass it at once to all columns?