Since the VectorAssembler
is crashing, if a passed column has any other type than NumericType
or BooleanType
and I'm dealing with a lot of TimestampType
columns, I want to know:
Is there a easy way, to cast multiple columns at once?
Based on this answer I already have a convenient way to cast a single column:
def castColumnTo(df: DataFrame,
columnName: String,
targetType: DataType ) : DataFrame = {
df.withColumn( columnName, df(columnName).cast(targetType) )
}
I thought about calling castColumnTo
recursively, but I strongly doubt that that's the (performant) way to go.