pyspark.sql.Column.cast¶
-
Column.
cast
(dataType: Union[pyspark.sql.types.DataType, str]) → pyspark.sql.column.Column¶ Casts the column into type
dataType
.Examples
>>> df.select(df.age.cast("string").alias('ages')).collect() [Row(ages='2'), Row(ages='5')] >>> df.select(df.age.cast(StringType()).alias('ages')).collect() [Row(ages='2'), Row(ages='5')]