这里不需要UDF。列已提供cast方法和datatype实例: frompyspark.sql.typesimportDoubleType changedTypedf = joindf.withColumn("label", joindf["show"].cast(DoubleType())) 或短字符串: changedTypedf = joindf.withColumn("label", joindf["show"].cast("double")) ...