Apache spark Pyspark将DF类型从Double更改为Int

Apache spark Pyspark将DF类型从Double更改为Int,apache-spark,dataframe,pyspark,Apache Spark,Dataframe,Pyspark,我正在学习Spark并使用CrossValidator。我的代码是: # Let's just reuse our CrossValidator with the new dtPipeline, RegressionEvaluator regEval, and 3 fold cross validation crossval.setEstimator(dtPipeline) # Let's tune over our dt.maxDepth parameter on the values 2

我正在学习Spark并使用CrossValidator。我的代码是:

# Let's just reuse our CrossValidator with the new dtPipeline,  RegressionEvaluator regEval, and 3 fold cross validation
crossval.setEstimator(dtPipeline)

# Let's tune over our dt.maxDepth parameter on the values 2 and 3, create a paramter grid using the ParamGridBuilder
paramGrid = ParamGridBuilder().addGrid(dt.maxDepth, [2.0, 3.0]).build()

# Add the grid to the CrossValidator
crossval.setEstimatorParamMaps(paramGrid)

# Now let's find and return the best model
dtModel = crossval.fit(trainingSetDF).bestModel 
当我编译它时,我有以下错误:

java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

有人知道怎么解决吗?

我解决了!maxDepth属性必须是整数,因此在函数addGrig中,我们对[2,3]进行了[2.0,3.0]运算。

我解决了这个问题!maxDepth属性必须是整数,因此在函数addGrig中,我们对[2,3]使用[2.0,3.0]。请注意,
df
标记用于该名称的Unix命令,与数据帧无关。请注意,
df
标记用于该名称的Unix命令,与数据帧无关。