我试图划分两个DF计数但得到0我认为我需要进行类型转换。你能帮帮我吗?
val subscribed = dataDF.where("Y='yes'").count
subscribed: Long = 5289
val Total = dataDF.count
Total: Long = 45211
val success = subscribed / Total
success: Long = 0
答案 0 :(得分:1)
您必须至少将其中一个变量转换为Double
:
val success = subscribed.toDouble / Total
//success: Double = 0.11698480458295547