Reputation: 117
I am trying to divide two DF count but getting 0 I think I need to do typecasting. Can you help me.
val subscribed = dataDF.where("Y='yes'").count
subscribed: Long = 5289
val Total = dataDF.count
Total: Long = 45211
val success = subscribed / Total
success: Long = 0
Upvotes: 0
Views: 114
Reputation: 24178
You have to cast at least one of the variables to Double
:
val success = subscribed.toDouble / Total
//success: Double = 0.11698480458295547
Upvotes: 1